docker / cli

The Docker CLI
Apache License 2.0
4.94k stars 1.93k forks source link

Missing validation for COPY --from #2496

Open mcandre opened 4 years ago

mcandre commented 4 years ago

If you have a typo in multistage names then Docker merrily marches along and reports a generic docker login issue instead of pointing out the name mismatch. :/

thaJeztah commented 4 years ago

When using COPY --from=<reference>, <reference> can be either the name of another stage, or an image (from Docker Hub / an image registry). In the latter case, docker does not know if the provided image exists, so cannot (upfront) know if the image exists, and will perform a docker pull to get that image (which will fail if it's not found).

For example, this Dockerfile will try to pull something:latest from Docker Hub

FROM busybox
COPY --from=something /foo /bar

Which will fail;

Sending build context to Docker daemon  2.048kB
Step 1/2 : FROM busybox
 ---> be5888e67be6
Step 2/2 : COPY --from=something /foo /bar
invalid from flag value something: pull access denied for something, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

Perhaps the error message could be improved.

@tonistiigi I think you were working on improved errors (at least for BuildKit); do you have a tracking issue for errors that need improvement?