3 DL4005
Miles Dai edited this page 2022-07-12 16:48:01 -04:00

Use SHELL to change the default shell

Problematic 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

Correct code:

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

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

Rationale:

Docker provides a SHELL instruction which does not require overwriting /bin/sh in your container.