Shellcheck: Dockerfile support

Created on 9 May 2018  路  3Comments  路  Source: koalaman/shellcheck

For new checks and feature suggestions

Dockerfiles seem to support a limited subset of shell scripts (and shell scripts can be embedded, which is currently quite nasty). It might be good to add this feature at some pont.

Most helpful comment

You'll love hadolint!

It's a linting tool for Dockerfiles, and it uses ShellCheck for RUN statements.

All 3 comments

Dockerfiles are not shell files they are config files for which there are already a few validators. Mixing languages is a bug; all shell scripts in dockerfiles should be called with

RUN ex.sh

@Dmole Would you call Dockerfiles and Makefiles actually used in many projects bugs too? I think the issue is not about what and who should use.

I would also like to lint embedded scripts (but it's not trivial and quite specific, so I doubt it will be implemented in shellcheck itself). A workaround for such cases is to use a wrapper than conditionally turn files into temporary scripts before linting them. As an illustration (really quick and dirty):

  • for Dockerfiles: shellcheck -s bash <(sed 's/^RUN //;' Dockerfile) (or even just shellcheck Dockerfile)
  • for Makefiles: shellcheck -s bash <(perl -pe 's/^(?!\t).*//' Makefile) (the substitution is to preserve line numbers)

You'll love hadolint!

It's a linting tool for Dockerfiles, and it uses ShellCheck for RUN statements.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ymkjp picture ymkjp  路  3Comments

sobolevn picture sobolevn  路  4Comments

erichelgeson picture erichelgeson  路  5Comments

erwinkramer picture erwinkramer  路  5Comments

koalaman picture koalaman  路  4Comments