hadolint / hadolint

Dockerfile linter, validate inline bash, written in Haskell
GNU General Public License v3.0
10.4k stars 422 forks source link

hadolint fails with DL1000 on variable expressions #1040

Open droopy4096 opened 1 month ago

droopy4096 commented 1 month ago

Expected behavior

pass linting

Actual behavior

error:

[
  {
    "code": "DL1000",
    "column": 39,
    "file": "repo1/gitlab-base/Dockerfile",
    "level": "error",
    "line": 40,
    "message": "unexpected ':'\nexpecting '@', '\\', a new line followed by the next instruction, or the image tag"
  }
]

Steps to reproduce the behavior

use variable expression in a Dockerfile:

# hadolint ignore=DL1000
FROM ${BASE_REGISTRY:-}${BASE_REGISTRY:+/}${BASE_IMAGE}:${BASE_TAG} 

most basic would be:

Output of hadolint --version or docker run --rm hadolint/hadolint hadolint --version or docker run --rm ghcr.io/hadolint/hadolint hadolint --version:

$ hadolint --version
Haskell Dockerfile Linter 2.12.0

Dockerfile (if relevant)

ARG BASE_REGISTRY=
ARG BASE_IMAGE=alpine
ARG BASE_TAG=latest

FROM ${BASE_REGISTRY:-}${BASE_REGISTRY:+/}${BASE_IMAGE}:${BASE_TAG} 

Additional environment details (OS, stack version, etc.)

droopy4096 commented 1 month ago

Support for variable expressions is mentioned in Dockerfile reference