Starting Directory for Bash
I've a Docker container running. I connect to the container using a command like:
docker exec -it container_name bash
This logs in as root at /var/www/html
. I want to know why this directory, and how I would go about changing it. This is actually a web application's container and I do want to start in the web applications content root, but that's on a differently named volume defined in the docker-compose.yml
file.
I checked .profile
and .bashrc
and nothing seems to indicate that it would start in this directory and be obvious to change.
Solution 1:
The working directory in a container is specified with WORKDIR
instruction in Dockerfile
. You can also change the working by specifying -w
parameter for docker run
or with working_dir
attribute in docker-compose.yml
.