I was taking an online tutorial in order to learn about dockerfiles. There was a quiz question:  The Dockerfile WORKDIR command changes directories:only for the rest of the Dockerfileas well as in the finished image.My selection (wrong) was: 1. only in the rest of the Dockerfile.  Could someone correct me by giving an example where the second (correct) answer could be of benefit?WORKDIR in the docs
Dockerfile WORKDIR persists in the image as well
docker
There are lots of times where you need to execute code from a specific directory, it could be that the application you are running manipulates files in the current directory, could be that the application expects config in the current directory, it could just be that the application is located in the current directory. WORKDIR allows the image creator to set this up so that people running the container do not need to worry about it.For example; one use case I have done before is creating a docker container with an application that manipulates files in the current directory. Without setting WORKDIR you would have to bind the volume to a location and then run cd /location for every command:docker -v $PWD:/location someimage cd /location; somecommandBy setting WORKDIR to /location you can drop the cd:docker -v $PWD:/location someimage somecommandWhich is allot more convenient.