Docker

Docker

Made by DeepSource

Use SHELL to change the default shell DOK-DL4005

Anti-pattern
Major

Docker provides a SHELL instruction allowing for changing the default shell for all subsequent RUN commands.

Manually changing shell is inefficient for two reasons. First, there is an un-necessary root shell processor invocation. Second, each RUN instruction in the shell form requires an extra shell command(/bin/sh -c) prefix.

Bad Practice

# 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

Recommended

# Install bash
RUN apk add --update-cache bash=4.3.42-r3

# Use bash as the default shell
SHELL ["/bin/bash", "-c"]