In both the SonarLint plugin for IntelliJ IDEA (version whatever is currently newest) and SonarQube developer edition (We’re using 10.3), rule docker:S6596 “Specific version tag for image should be used” us triggered on multi-stage docker builds. For example, consider the following Dockerfile:
# syntax=docker/dockerfile:1
ARG NODE_VERSION=20.10.0
################################################################################
# Use node image for base image for all stages.
ARG PREFIX="${PRIVATE_REGISTRY}/docker-hub-proxy/"
FROM ${PREFIX}node:${NODE_VERSION}-alpine AS base
# Set working directory for all build stages.
WORKDIR /usr/src/app
# Install dependencies frontend
FROM base AS deps-fe
COPY frontend ./fe
WORKDIR ./fe
RUN npm ci
Rule docker:S6596 triggers on the FROM base AS deps-fe
line, stating a specific version tag should be used for the base
image. This rule should not trigger on references to previous build stages of the same Dockerfile.
Rule specification:
Rule introduced: