dockerfile-linter icon indicating copy to clipboard operation
dockerfile-linter copied to clipboard

Enhance 'pipefail' warnings

Open srcshelton opened this issue 4 years ago • 0 comments

When a RUN block contains a pipeline, not having set pipefail results in:

/ER0001/ Set the SHELL option -o(-eo for Alpine image) pipefail before RUN with a pipe in

... whilst having set pipefail (correctly) by default gives:

/SC2039/ In POSIX sh, set option pipefail is undefined.

I'm not sure of a good solution to this since docker/podman/buildah use the container's sh rather than a bundled standardised version - the -s option can be set on the command-line, but is there a directive which sets this and can be used inline in a file.

Also, using set -o pipefail at the top of a block containing a pipeline doesn't quell the warning when the pipeline (for which pipefail is now active) is encountered - in fact, all of these generate ER0001:

RUN set -o pipefail ; \
    ... \
    cmd1 | cmd2
RUN set -o pipefail && \
    ... \
    cmd1 | cmd2
RUN ... \
    set -o pipefail ; cmd1 | cmd2
RUN ... \
    set -o pipefail && cmd1 | cmd2

... so I'm unsure as to what syntax can be used to avoid triggering this error.

srcshelton avatar Jun 30 '20 20:06 srcshelton