Skip to content

no-shell-symlink

Dockerfilesuspiciousno fixdefault: offdockerfile/hadolint

Reports a RUN that replaces /bin/sh. That is an ln command with /bin/sh among its arguments (ln -sf /bin/bash /bin/sh).

Replacing /bin/sh changes the shell that every script of the image, and of the packages you install, expects to be a POSIX sh. Scripts that start with #!/bin/sh then run under another shell than the one they were written for, and package scripts can fail in odd ways.

To use another shell for the build, the SHELL instruction (SHELL ["/bin/bash", "-c"]) changes only the shell of the later RUN instructions.

Reported
...
RUN wget -q https://example.com/f
RUN ln -sf /bin/bash /bin/sh
RUN echo sudo cd ps
...
sudo make install
...
dockerfile:
lint:
rules:
no-shell-symlink: warn # off (default), warn, error

Enabled by the presets: dockerfile/hadolint.

Suppress one line with sudsy-disable-next-line no-shell-symlink in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
hadolint DL4005 full