invalid reference format when building a Docker Image
up vote
0
down vote
favorite
I have the following lines in a Dockerfile:
ARG SOMEARGUMENT
COPY --from=$SOMEARGUMENT /some/path/goes/here
where SOMEARGUMENT could be either "some/repository:1.1.1" or "some/repository:2.2.2"
But when trying to build I always get the error:
invalid reference format: repository name must be lowercase
So it is obvious that the argument passed when building the image (i.e. SOMEARGUMENT) is not being resolved.
Is it actaully possible to do something like this in a Dockerfile?
Thanks.
docker dockerfile
add a comment |
up vote
0
down vote
favorite
I have the following lines in a Dockerfile:
ARG SOMEARGUMENT
COPY --from=$SOMEARGUMENT /some/path/goes/here
where SOMEARGUMENT could be either "some/repository:1.1.1" or "some/repository:2.2.2"
But when trying to build I always get the error:
invalid reference format: repository name must be lowercase
So it is obvious that the argument passed when building the image (i.e. SOMEARGUMENT) is not being resolved.
Is it actaully possible to do something like this in a Dockerfile?
Thanks.
docker dockerfile
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have the following lines in a Dockerfile:
ARG SOMEARGUMENT
COPY --from=$SOMEARGUMENT /some/path/goes/here
where SOMEARGUMENT could be either "some/repository:1.1.1" or "some/repository:2.2.2"
But when trying to build I always get the error:
invalid reference format: repository name must be lowercase
So it is obvious that the argument passed when building the image (i.e. SOMEARGUMENT) is not being resolved.
Is it actaully possible to do something like this in a Dockerfile?
Thanks.
docker dockerfile
I have the following lines in a Dockerfile:
ARG SOMEARGUMENT
COPY --from=$SOMEARGUMENT /some/path/goes/here
where SOMEARGUMENT could be either "some/repository:1.1.1" or "some/repository:2.2.2"
But when trying to build I always get the error:
invalid reference format: repository name must be lowercase
So it is obvious that the argument passed when building the image (i.e. SOMEARGUMENT) is not being resolved.
Is it actaully possible to do something like this in a Dockerfile?
Thanks.
docker dockerfile
docker dockerfile
asked Nov 8 at 13:00
eindemwort
386
386
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
Since you always base on the same repo, it's cleaner to do like this.
ARG VERSION
FROM some/repository:$VERSION as builder
RUN mkdir test
FROM scratch
COPY --from=builder /test /
Source:
https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
interesting. I was not aware of this behavior. Can you point me to the documentation on how this can be used? Thanks.
– Stefano
Nov 8 at 13:54
@Stefano see updated answer
– Siyu
Nov 8 at 14:01
Thanks Siyu for your answer. I just tested it , but it is not working. I removed the FROM scratch instructions and I am making another test, but at least I see some progress in the console output. Do you know why is this "FROM scratch" instruction there?
– eindemwort
Nov 8 at 14:32
@eindemwort you can't remove the secondFROM
: these 2FROM
are forming a multi-stage build which enables you to doCOPY --from
. I'm usingFROM scratch
just to make this point, it doesn't have to be it, a common last stage could beFROM alpine
which is a small linux image. It will be helpful if you tell us why do you want this kind of behavior.
– Siyu
Nov 8 at 14:42
Thanks @Siyu! Your help was very useful!
– eindemwort
Nov 8 at 15:54
add a comment |
up vote
1
down vote
Expanding on Siyu answer.
A possible solution to your questions can be the following:
Dockerfile:
ARG SOMEARGUMENT
ARG SOMEVERSION=latest
FROM $SOMEARGUMENT:$SOMEVERSION as thebase
RUN echo "This is a test" > /test.txt
FROM alpine:latest
COPY --from=thebase /test.txt /success.txt
CMD cat /success.txt
Command to build:
docker build --build-arg SOMEARGUMENT=alpine --tag test .
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Since you always base on the same repo, it's cleaner to do like this.
ARG VERSION
FROM some/repository:$VERSION as builder
RUN mkdir test
FROM scratch
COPY --from=builder /test /
Source:
https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
interesting. I was not aware of this behavior. Can you point me to the documentation on how this can be used? Thanks.
– Stefano
Nov 8 at 13:54
@Stefano see updated answer
– Siyu
Nov 8 at 14:01
Thanks Siyu for your answer. I just tested it , but it is not working. I removed the FROM scratch instructions and I am making another test, but at least I see some progress in the console output. Do you know why is this "FROM scratch" instruction there?
– eindemwort
Nov 8 at 14:32
@eindemwort you can't remove the secondFROM
: these 2FROM
are forming a multi-stage build which enables you to doCOPY --from
. I'm usingFROM scratch
just to make this point, it doesn't have to be it, a common last stage could beFROM alpine
which is a small linux image. It will be helpful if you tell us why do you want this kind of behavior.
– Siyu
Nov 8 at 14:42
Thanks @Siyu! Your help was very useful!
– eindemwort
Nov 8 at 15:54
add a comment |
up vote
1
down vote
accepted
Since you always base on the same repo, it's cleaner to do like this.
ARG VERSION
FROM some/repository:$VERSION as builder
RUN mkdir test
FROM scratch
COPY --from=builder /test /
Source:
https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
interesting. I was not aware of this behavior. Can you point me to the documentation on how this can be used? Thanks.
– Stefano
Nov 8 at 13:54
@Stefano see updated answer
– Siyu
Nov 8 at 14:01
Thanks Siyu for your answer. I just tested it , but it is not working. I removed the FROM scratch instructions and I am making another test, but at least I see some progress in the console output. Do you know why is this "FROM scratch" instruction there?
– eindemwort
Nov 8 at 14:32
@eindemwort you can't remove the secondFROM
: these 2FROM
are forming a multi-stage build which enables you to doCOPY --from
. I'm usingFROM scratch
just to make this point, it doesn't have to be it, a common last stage could beFROM alpine
which is a small linux image. It will be helpful if you tell us why do you want this kind of behavior.
– Siyu
Nov 8 at 14:42
Thanks @Siyu! Your help was very useful!
– eindemwort
Nov 8 at 15:54
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Since you always base on the same repo, it's cleaner to do like this.
ARG VERSION
FROM some/repository:$VERSION as builder
RUN mkdir test
FROM scratch
COPY --from=builder /test /
Source:
https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
Since you always base on the same repo, it's cleaner to do like this.
ARG VERSION
FROM some/repository:$VERSION as builder
RUN mkdir test
FROM scratch
COPY --from=builder /test /
Source:
https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
edited Nov 8 at 14:01
answered Nov 8 at 13:40
Siyu
633313
633313
interesting. I was not aware of this behavior. Can you point me to the documentation on how this can be used? Thanks.
– Stefano
Nov 8 at 13:54
@Stefano see updated answer
– Siyu
Nov 8 at 14:01
Thanks Siyu for your answer. I just tested it , but it is not working. I removed the FROM scratch instructions and I am making another test, but at least I see some progress in the console output. Do you know why is this "FROM scratch" instruction there?
– eindemwort
Nov 8 at 14:32
@eindemwort you can't remove the secondFROM
: these 2FROM
are forming a multi-stage build which enables you to doCOPY --from
. I'm usingFROM scratch
just to make this point, it doesn't have to be it, a common last stage could beFROM alpine
which is a small linux image. It will be helpful if you tell us why do you want this kind of behavior.
– Siyu
Nov 8 at 14:42
Thanks @Siyu! Your help was very useful!
– eindemwort
Nov 8 at 15:54
add a comment |
interesting. I was not aware of this behavior. Can you point me to the documentation on how this can be used? Thanks.
– Stefano
Nov 8 at 13:54
@Stefano see updated answer
– Siyu
Nov 8 at 14:01
Thanks Siyu for your answer. I just tested it , but it is not working. I removed the FROM scratch instructions and I am making another test, but at least I see some progress in the console output. Do you know why is this "FROM scratch" instruction there?
– eindemwort
Nov 8 at 14:32
@eindemwort you can't remove the secondFROM
: these 2FROM
are forming a multi-stage build which enables you to doCOPY --from
. I'm usingFROM scratch
just to make this point, it doesn't have to be it, a common last stage could beFROM alpine
which is a small linux image. It will be helpful if you tell us why do you want this kind of behavior.
– Siyu
Nov 8 at 14:42
Thanks @Siyu! Your help was very useful!
– eindemwort
Nov 8 at 15:54
interesting. I was not aware of this behavior. Can you point me to the documentation on how this can be used? Thanks.
– Stefano
Nov 8 at 13:54
interesting. I was not aware of this behavior. Can you point me to the documentation on how this can be used? Thanks.
– Stefano
Nov 8 at 13:54
@Stefano see updated answer
– Siyu
Nov 8 at 14:01
@Stefano see updated answer
– Siyu
Nov 8 at 14:01
Thanks Siyu for your answer. I just tested it , but it is not working. I removed the FROM scratch instructions and I am making another test, but at least I see some progress in the console output. Do you know why is this "FROM scratch" instruction there?
– eindemwort
Nov 8 at 14:32
Thanks Siyu for your answer. I just tested it , but it is not working. I removed the FROM scratch instructions and I am making another test, but at least I see some progress in the console output. Do you know why is this "FROM scratch" instruction there?
– eindemwort
Nov 8 at 14:32
@eindemwort you can't remove the second
FROM
: these 2 FROM
are forming a multi-stage build which enables you to do COPY --from
. I'm using FROM scratch
just to make this point, it doesn't have to be it, a common last stage could be FROM alpine
which is a small linux image. It will be helpful if you tell us why do you want this kind of behavior.– Siyu
Nov 8 at 14:42
@eindemwort you can't remove the second
FROM
: these 2 FROM
are forming a multi-stage build which enables you to do COPY --from
. I'm using FROM scratch
just to make this point, it doesn't have to be it, a common last stage could be FROM alpine
which is a small linux image. It will be helpful if you tell us why do you want this kind of behavior.– Siyu
Nov 8 at 14:42
Thanks @Siyu! Your help was very useful!
– eindemwort
Nov 8 at 15:54
Thanks @Siyu! Your help was very useful!
– eindemwort
Nov 8 at 15:54
add a comment |
up vote
1
down vote
Expanding on Siyu answer.
A possible solution to your questions can be the following:
Dockerfile:
ARG SOMEARGUMENT
ARG SOMEVERSION=latest
FROM $SOMEARGUMENT:$SOMEVERSION as thebase
RUN echo "This is a test" > /test.txt
FROM alpine:latest
COPY --from=thebase /test.txt /success.txt
CMD cat /success.txt
Command to build:
docker build --build-arg SOMEARGUMENT=alpine --tag test .
add a comment |
up vote
1
down vote
Expanding on Siyu answer.
A possible solution to your questions can be the following:
Dockerfile:
ARG SOMEARGUMENT
ARG SOMEVERSION=latest
FROM $SOMEARGUMENT:$SOMEVERSION as thebase
RUN echo "This is a test" > /test.txt
FROM alpine:latest
COPY --from=thebase /test.txt /success.txt
CMD cat /success.txt
Command to build:
docker build --build-arg SOMEARGUMENT=alpine --tag test .
add a comment |
up vote
1
down vote
up vote
1
down vote
Expanding on Siyu answer.
A possible solution to your questions can be the following:
Dockerfile:
ARG SOMEARGUMENT
ARG SOMEVERSION=latest
FROM $SOMEARGUMENT:$SOMEVERSION as thebase
RUN echo "This is a test" > /test.txt
FROM alpine:latest
COPY --from=thebase /test.txt /success.txt
CMD cat /success.txt
Command to build:
docker build --build-arg SOMEARGUMENT=alpine --tag test .
Expanding on Siyu answer.
A possible solution to your questions can be the following:
Dockerfile:
ARG SOMEARGUMENT
ARG SOMEVERSION=latest
FROM $SOMEARGUMENT:$SOMEVERSION as thebase
RUN echo "This is a test" > /test.txt
FROM alpine:latest
COPY --from=thebase /test.txt /success.txt
CMD cat /success.txt
Command to build:
docker build --build-arg SOMEARGUMENT=alpine --tag test .
answered Nov 8 at 14:28
Stefano
1,031615
1,031615
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53208277%2finvalid-reference-format-when-building-a-docker-image%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password