There is no explanation in docker doc or seemingly any builtin variable in docker to find the original working directory where the image is being built. I want to run commands on different directories and at some point get back to where i launched docker build from. Am I missing something obvious? Thanks.
Dockerfile example:
FROM ubuntu
WORKDIR /my_folder
RUN command1
WORKDIR ??? // How do i get back to the Dockerfile folder?
RUN command2
The WORKDIR
directive is really just cd
for your Dockerfile.
Your original working directory inside the container is /
. You can get back there by:
WORKDIR /
Remember, this is affecting the context of the containerized build environment, and has nothing to do with where your Dockerfile is located.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With