0

I can't seem to be able to use a $VARIABLE reference in --from part of COPY instruction

$ docker build - <<<'
> ARG DOCKER_REGISTRY=docker.io
FROM $DOCKER_REGISTRY/library/docker:24-cli

ENV DOCKER_REGISTRY=$DOCKER_REGISTRY
COPY --from=$DOCKER_REGISTRY/kcov/kcov:latest-alpine /usr/local/bin/kcov* /usr/local/bin/
'
[+] Building 0.0s (2/2) FINISHED                                                                                                                                                                                       docker:default
 => [internal] load build definition from Dockerfile                                                                                                                                                                             0.0s
 => => transferring dockerfile: 243B                                                                                                                                                                                             0.0s
 => CANCELED [internal] load metadata for docker.io/library/docker:24-cli                                                                                                                                                        0.0s
Dockerfile:6
--------------------
   4 |     
   5 |     ENV DOCKER_REGISTRY=$DOCKER_REGISTRY
   6 | >>> COPY --from=$DOCKER_REGISTRY/kcov/kcov:latest-alpine /usr/local/bin/kcov* /usr/local/bin/
   7 |     
   8 |     
--------------------
ERROR: failed to solve: failed to parse stage name "$DOCKER_REGISTRY/kcov/kcov:latest-alpine": invalid reference format

Is it supported? There is nothing in the documentation suggesting you can't use build args there.

How else can I parametrize the registry there? (We have an internal proxy of docker hub, that I don't want to hardcode)

The ENV statement doesn't make a difference, I added it just in case it would.

2
  • This question is being discussed on meta. Commented Jul 3 at 6:17
  • well, there's not much actual discussion ATM :) Commented Jul 3 at 12:29

1 Answer 1

1

As I wrote this I realized I can declare

FROM $DOCKER_REGISTRY/kcov/kcov:latest-alpine AS kcov

then use

COPY --from=kcov /

Still, it's strange that the build argument is not resolved there

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.