Skip to content

[20.10] Classic builder silently ignores unsupported Dockerfile command flags #41911

@thaJeztah

Description

@thaJeztah

With the promotion of the experimental Dockerfile syntax to "stable", the Dockerfile syntax now includes some options that are supported by BuildKit, but not (yet) supported in the classic builder.

As a result, parsing a Dockerfile may succeed, but any flag that's known to BuildKit, but not supported by the classic builder is silently ignored;

$ mkdir buildkit_flags && cd buildkit_flags
$ touch foo.txt

For example, RUN --mount:

$ DOCKER_BUILDKIT=0 docker build --no-cache -f- . <<EOF
FROM busybox
RUN --mount=type=cache,target=/foo echo hello
EOF
Sending build context to Docker daemon  2.095kB
Step 1/2 : FROM busybox
 ---> 219ee5171f80
Step 2/2 : RUN --mount=type=cache,target=/foo echo hello
 ---> Running in 022fdb856bc8
hello
Removing intermediate container 022fdb856bc8
 ---> e9f0988844d1
Successfully built e9f0988844d1

Or COPY --chmod (same for ADD --chmod):

DOCKER_BUILDKIT=0 docker build --no-cache -f- . <<EOF
FROM busybox
COPY --chmod=0777 /foo.txt /foo.txt
EOF
Sending build context to Docker daemon  2.095kB
Step 1/2 : FROM busybox
 ---> 219ee5171f80
Step 2/2 : COPY --chmod=0777 /foo.txt /foo.txt
 ---> 8b7117932a2a
Successfully built 8b7117932a2a

Note that unknown flags still produce and error, for example, the below fails because --hello is an unknown flag;

DOCKER_BUILDKIT=0 docker build -<<EOF
FROM busybox
RUN --hello echo hello
EOF
Sending build context to Docker daemon  2.048kB
Error response from daemon: dockerfile parse error line 2: Unknown flag: hello

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.version/20.10

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions