Skip to content

Files

Latest commit

 

History

History
29 lines (18 loc) · 720 Bytes

DL3003.md

File metadata and controls

29 lines (18 loc) · 720 Bytes

Pattern: Use of cd in Dockerfile

Issue: -

Description

Most commands can work with absolute paths without changing directories. Docker provides the WORKDIR instruction if you really need to change the current working directory.

Example of incorrect code:

RUN cd /usr/src/app && git clone git@github.com:lukasmartinelli/hadolint.git 

Example of correct code:

RUN git clone git@github.com:lukasmartinelli/hadolint.git /usr/src/app

Exceptions

When executed in a Subshell.

Further Reading