Use SHELL to change the default shell
19# them by prefixing each apt-get statement with DEBIAN_FRONTEND=noninteractive
20RUN apt-get update && apt-get install python3 python-software-properties software-properties-common postgresql postgresql-client postgresql-contrib wget curl bash
21
22RUN ln -sfv /bin/bash /bin/sh23
24# Switch to the postgres home directory to set up files there.
25RUN alias server_uptime='ssh $host 'uptime -p''
Description
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"]