Set A Default Working Directory

Create Dockerfile

# Build from base image
FROM ubuntu:latest

# Set a default working directory to tmp/

Build Image From Dockerfile

Build the Dockerfile (docker build) in the current directory (.) and call the image chrisalbon/big-project:working-directory (--tag chrisalbon/big-project:working-directory).

docker build --tag chrisalbon/big-project:working-directory .
Sending build context to Docker daemon  4.608kB
Step 1/2 : FROM ubuntu:latest
 ---> 1e4467b07108
Step 2/2 : WORKDIR tmp/
 ---> Running in 9937480bdea0
Removing intermediate container 9937480bdea0
 ---> 89173bdc678a
Successfully built 89173bdc678a
Successfully tagged chrisalbon/big-project:working-directory

Run Docker Container From Image

Start and create (docker run) an interative (-it) Docker container called copy-example (--name working-directory) from the image called chrisalbon/big-project:working-directory. Open a shell (/bin/bash). Remove the container after it stops (-rm)

docker container run -it --name working-directory chrisalbon/big-project:working-directory /bin/bash
[email protected]:/tmp# 

Notice that when the container runs the working directory is tmp