Docker

Docker

Made by DeepSource

Use WORKDIR to switch to a directory DOK-DL3003

Anti-pattern
Minor

Only use cd in a subshell. Most commands can work with absolute paths and in most cases, it is not necessary to change directories. Docker provides the WORKDIR instruction if you really need to change the current working directory.

Also note that any changes to the environment or working directory within a RUN command will not stay in effect in subsequent lines.

Bad Practice

FROM debian:buster
RUN cd /usr/src/app && git clone [email protected]:lukasmartinelli/hadolint.git

Recommended

FROM debian:buster
WORKDIR /usr/src/app
RUN git clone [email protected]:lukasmartinelli/hadolint.git