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.










share|improve this question

























    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.










    share|improve this question























      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.










      share|improve this question













      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 8 at 13:00









      eindemwort

      386




      386






















          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






          share|improve this answer






















          • 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 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

















          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 .





          share|improve this answer




















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            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






























            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






            share|improve this answer






















            • 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 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














            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






            share|improve this answer






















            • 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 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












            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






            share|improve this answer














            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







            share|improve this answer














            share|improve this answer



            share|improve this answer








            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 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
















            • 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 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















            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












            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 .





            share|improve this answer
























              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 .





              share|improve this answer






















                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 .





                share|improve this answer












                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 .






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 8 at 14:28









                Stefano

                1,031615




                1,031615



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    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














































































                    Popular posts from this blog

                    𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

                    Crossroads (UK TV series)

                    ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế