Skip to content

hadolint/DL3059

Multiple consecutive RUN instructions.

Superseded by tally/prefer-run-heredoc, which provides the same check with enhanced detection (consecutive RUNs and chained commands) and auto-fix support using heredoc syntax.

Description

Multiple consecutive RUN instructions can be consolidated into a single instruction to reduce image layers.

Examples

Problematic code

FROM ubuntu
RUN apt-get update
RUN apt-get install -y curl

Correct code

FROM ubuntu
RUN apt-get update && apt-get install -y curl

Or with heredoc syntax (tally auto-fix):

FROM ubuntu
RUN <<EOF
apt-get update
apt-get install -y curl
EOF

Reference