The WORKDIR instruction

The WORKDIR instruction changes the current working directory from / to the path specified by this instruction. The ensuing instructions, such as RUN, CMD, and ENTRYPOINT will also work on the directory set by the WORKDIR instruction.

The following line gives the appropriate syntax for the WORKDIR instruction:

WORKDIR <dirpath> 

Here, <dirpath> is the path for the working directory to set in. The path can be either absolute or relative. In the case of a relative path, it will be relative to the previous path set by the WORKDIR instruction. If the specified directory is not found in the target image filesystem, then the directory will be created.

The following line is a clear example of the WORKDIR instruction in a Dockerfile:

WORKDIR /var/log 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset