Pattern: Missing use of SHELL
instruction
Issue: -
Docker provides a SHELL
instruction which does not require overwriting /bin/sh
in your container.
The SHELL
instruction is particularly useful on Windows where there are two commonly used and quite different native shells: cmd
and powershell
, as well as alternate shells available including sh
.
Example of incorrect code:
# Install bash
RUN apk add --update-cache bash=4.3.42-r3
# Use bash as the default shell
RUN ln -sfv /bin/bash /bin/sh
Example of correct code:
# Install bash
RUN apk add --update-cache bash=4.3.42-r3
# Use bash as the default shell
SHELL ["/bin/bash", "-c"]