koalaman/shellcheck

By koalaman

Updated 3 months ago

ShellCheck -- Shell script analysis tool

Image
42

10M+

koalaman/shellcheck

This is the official Docker image for ShellCheck, a static analysis tool for shell scripts.

USAGE

Run the latest git commit from the command line

$ docker run --rm -it -v "$(pwd):/mnt" koalaman/shellcheck:latest --version
ShellCheck - shell script analysis tool
version: v0.10.0-62-g3c75d82
license: GNU General Public License, version 3
website: https://www.shellcheck.net

Create a shell alias

Add the following to your .bashrc or equivalent:

alias shellcheck='docker run --rm -it -v "$(pwd):/mnt" koalaman/shellcheck:stable'

then restart your terminal and run shellcheck --version

Incorporate into your CI workflow

By glob:

$ docker run --rm -it -v "$(pwd):/mnt" koalaman/shellcheck:stable *.sh

Or recursively, by filename:

find . -name '*.sh' -exec docker run --rm -it -v "$(pwd):/mnt" koalaman/shellcheck:stable {} +

Or recursively, trying to recognize shebangs:

find . -type f -exec grep -q '^#!.*sh' {} \; -exec docker run --rm -it -v "$(pwd):/mnt" koalaman/shellcheck:stable {} +

For smarter script identification and version auto-upgrade, check out the shellcheck pre-commit plugin.

(Tip: replace stable with a specific version like v0.10.0 to avoid breaking your build when a new version is released.)

Run with Linux utilities

Note that this image does not contain any Unix userspace utilities.

If you prefer that, check out koalaman/shellcheck-alpine. That Docker image has an Alpine Linux set of userspace tools, with the shellcheck binary added.

Include in your own Docker image

You can copy the statically linked shellcheck binary into your own image, such as with this minimal Dockerfile:

FROM alpine:latest
COPY --from=koalaman/shellcheck:stable /bin/shellcheck /bin/

Docker Pull Command

docker pull koalaman/shellcheck