The WORKDIR
is directory where you’ll do your RUN
command or CMD
command.
to find out, create the image with the simple Dockerfile below
FROM nginx:latest
WORKDIR /some/path/to/some/file/and/if/not/exists/it/will/create/it/
RUN touch create_a_file.md
when you do
docker container run -it mynginx bash
youl’ll find yourself in the directory /some/path/to/some/file/and/if/not/exists/it/will/create/it
. and if you do ls
, you’ll find there’s a file called create_a_file.md
in the directory.
You can change the WORKDIR
many times to preform different tasks in the Dockerfile.