Dockerfile:
FROM busybox
RUN mkdir -p /foo/bar
RUN echo baz > /foo/bar/baz
FROM busybox
RUN mkdir -p /foo
COPY --from=0 /foo/* /foo/
Without BuildKit:
$ DOCKER_BUILDKIT=0 docker build -q -t foo . && docker run -it --rm foo ls -lR /foo
sha256:f0cb94f3ce439aaee90584a97fa0cc0b842c59eb5ea807a0300a7ae0ed15f6ef
/foo:
total 4
-rw-r--r-- 1 root root 4 Oct 25 07:35 baz
With BuildKit:
$ DOCKER_BUILDKIT=1 docker build -q -t foo . && docker run -it --rm foo ls -lR /foo
sha256:32b3ef586ddf778cd8cf98bac2fe0f3bce93efa649d76647e9e8ee7d153c1b77
/foo:
total 4
drwxr-xr-x 2 root root 4096 Oct 25 07:35 bar
/foo/bar:
total 4
-rw-r--r-- 1 root root 4 Oct 25 07:35 baz
docker version:
$ docker version
Client:
Version: master-dockerproject-2018-10-24
API version: 1.39
Go version: go1.11.1
Git commit: 15e40e7e
Built: Wed Oct 24 23:39:36 2018
OS/Arch: linux/amd64
Experimental: true
Server:
Engine:
Version: master-dockerproject-2018-10-24
API version: 1.39 (minimum version 1.12)
Go version: go1.11.1
Git commit: bc4c1c2
Built: Wed Oct 24 23:48:05 2018
OS/Arch: linux/amd64
Experimental: true
Found in https://github.com/rootless-containers/usernetes/issues/50 (https://github.com/rootless-containers/usernetes/blob/af677af8c3f68f644468a531795e40a6f75287c8/build/crio.Dockerfile#L38)
Although actually I think BuildKit behavior is more "correct", but I set bug label because of incompatibility.
Really hard to see how the old behavior makes any sense. Could we consider it a bug? Knowing the wildcard implementation of the legacy builder I have a pretty good idea why the legacy one does that and it seems like an oversight of that implementation. @tiborvass
In these cases, the question is what do people expect. I would argue that the legacy behavior was always non-intuitive and buggy. The other thing is, I really doubt many people are relying on this ~feature~ bug and those that do, can easily fix it by changing COPY --from=0 /foo/* /foo/ to COPY --from=0 /foo/*/* /foo/. I'm closing this but feel free to discuss.
Most helpful comment
Really hard to see how the old behavior makes any sense. Could we consider it a bug? Knowing the wildcard implementation of the legacy builder I have a pretty good idea why the legacy one does that and it seems like an oversight of that implementation. @tiborvass