Skip to content

No error if build args are missing during docker build  #37325

@abhi

Description

@abhi

Description
It appears that if the build args is not passed to docker build and the Dockerfile consumes this argument, docker build doesnt report an error even thought the build args are missing.
This has been seen on docker 17.09-ce till 18.05-ce.

On 17.06-ee, this would report the following error.

Step 5/8 : FROM ${ALPINE}
invalid reference format

Steps to reproduce the issue:

Describe the results you received:

Dockerfile:

ARG SOMETHING
ARG ALPINE

FROM ${SOMETHING} as builder
# No actual build steps, just copying

FROM ${ALPINE}

EXPOSE 8080
$ docker build --build-arg SOMETHING=redis -f Dockerfile .
Sending build context to Docker daemon  2.048kB
Step 1/5 : ARG SOMETHING
Step 2/5 : ARG ALPINE
Step 3/5 : FROM ${SOMETHING} as builder
latest: Pulling from library/redis
f2aa67a397c4: Pull complete
298c0b953ff5: Pull complete
54481933a13d: Pull complete
e236faec6ff6: Pull complete
93540029cb59: Pull complete
1c88aa70d0e2: Pull complete
Digest: sha256:c389a35832492c42f4719776471f9a42d2fc5a8ba0077ba25746626b09eab880
Status: Downloaded newer image for redis:latest
 ---> 55cb7014c24f
Step 4/5 : FROM ${ALPINE}
 --->
Step 5/5 : EXPOSE 8080
 ---> Running in 428dd57f037d
Removing intermediate container 428dd57f037d
 ---> e0f93b8c2347
Successfully built e0f93b8c2347

Describe the results you expected:

$ docker build --build-arg SOMETHING=redis -f Dockerfile .
Sending build context to Docker daemon  2.048kB
Step 1/5 : ARG SOMETHING
Step 2/5 : ARG ALPINE
Step 3/5 : FROM ${SOMETHING} as builder
latest: Pulling from library/redis
f2aa67a397c4: Pull complete
298c0b953ff5: Pull complete
54481933a13d: Pull complete
e236faec6ff6: Pull complete
93540029cb59: Pull complete
1c88aa70d0e2: Pull complete
Digest: sha256:c389a35832492c42f4719776471f9a42d2fc5a8ba0077ba25746626b09eab880
Status: Downloaded newer image for redis:latest
 ---> 55cb7014c24f
Step 4/5 : FROM ${ALPINE}
 invalid reference format

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

(paste your output here)

Output of docker info:

(paste your output here)

Additional environment details (AWS, VirtualBox, physical, etc.):

ping @tonistiigi

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/builderBuildkind/bugBugs are bugs. The cause may or may not be known at triage time so debugging may be needed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions