Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ONBUILD COPY --from does not work #185

Closed
andrewrynhard opened this issue Oct 31, 2019 · 1 comment
Closed

ONBUILD COPY --from does not work #185

andrewrynhard opened this issue Oct 31, 2019 · 1 comment

Comments

@andrewrynhard
Copy link

andrewrynhard commented Oct 31, 2019

Using the following Dockerfiles:

base.dockerfile:

FROM alpine
ONBUILD COPY --from=extra / /extra

extra.dockerfile:

FROM scratch AS extra
COPY --from=alpine /lib /

FROM docker.io/andrewrynhard/base:latest

I am able to get the following to work without buildx:

$ docker build -t docker.io/andrewrynhard/base:latest -f base.dockerfile .
Sending build context to Docker daemon  89.81MB
Step 1/2 : FROM alpine
latest: Pulling from library/alpine
89d9c30c1d48: Pull complete
Digest: sha256:c19173c5ada610a5989151111163d28a67368362762534d8a8121ce95cf2bd5a
Status: Downloaded newer image for alpine:latest
 ---> 965ea09ff2eb
Step 2/2 : ONBUILD COPY --from=extra / /extra
 ---> Running in 882c8bb8dc57
Removing intermediate container 882c8bb8dc57
 ---> 62bab3d925f1
Successfully built 62bab3d925f1
Successfully tagged base:latest
$ docker build -t extra -f extra.dockerfile .
Sending build context to Docker daemon  89.81MB
Step 1/3 : FROM scratch AS extra
 --->
Step 2/3 : COPY --from=alpine /lib /
 ---> b6d5b611c2a2
Step 3/3 : FROM base
# Executing 1 build trigger
 ---> 08c407fa8f46
Successfully built 08c407fa8f46
Successfully tagged extra:latest
$ docker run --rm -it extra:latest find /extra
/extra
/extra/libssl.so.1.1
/extra/ld-musl-x86_64.so.1
/extra/libcrypto.so.1.1
/extra/mdev
/extra/libz.so.1
/extra/apk
/extra/apk/db
/extra/apk/db/lock
/extra/apk/db/scripts.tar
/extra/apk/db/installed
/extra/apk/db/triggers
/extra/libz.so.1.2.11
/extra/libc.musl-x86_64.so.1
/extra/firmware

But this does not work using buildx (using the same docker.io/andrewrynhard/base:latest image):

$ docker buildx build -t extra -f extra.dockerfile --load .
[+] Building 1.4s (7/7) FINISHED
 => [internal] load .dockerignore                                                                                                                                                                          0.0s
 => => transferring context: 2B                                                                                                                                                                            0.0s
 => [internal] load build definition from extra.dockerfile                                                                                                                                                 0.0s
 => => transferring dockerfile: 133B                                                                                                                                                                       0.0s
 => [internal] load metadata for docker.io/andrewrynhard/base:latest                                                                                                                                       1.0s
 => CACHED [stage-1 1/1] FROM docker.io/andrewrynhard/base:latest@sha256:7a28354691d9a0f39a5464a843b3e5777f6dc71bdaae0addb1c905e8a89d43db                                                                  0.0s
 => => resolve docker.io/andrewrynhard/base:latest@sha256:7a28354691d9a0f39a5464a843b3e5777f6dc71bdaae0addb1c905e8a89d43db                                                                                 0.0s
 => [stage-1 2/1] COPY --from=extra / /extra                                                                                                                                                               0.0s
 => exporting to oci image format                                                                                                                                                                          0.3s
 => => exporting layers                                                                                                                                                                                    0.1s
 => => exporting manifest sha256:3e9f962e876a8800177305e375b6970b93a7c9f3a08fa87211dfc8cb7628a968                                                                                                          0.0s
 => => exporting config sha256:655fd9064dc1b13e89fe3de444255e9eb3602d211c536aee9416565f1b9554f9                                                                                                            0.0s
 => => sending tarball                                                                                                                                                                                     0.1s
 => importing to docker                                                                                                                                                                                    0.1s
$ docker run --rm -it extra:latest find /extra
/extra
@tonistiigi
Copy link
Member

Thanks for the report. Closing as dupe of moby/buildkit#816

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants