Skip to content

Latest commit

 

History

History
34 lines (22 loc) · 898 Bytes

DL4005.md

File metadata and controls

34 lines (22 loc) · 898 Bytes

Pattern: Missing use of SHELL instruction

Issue: -

Description

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"]

Further Reading