Extend a stage of Multi-stage built image on docker hub












0















With the support of the multi-stage builds, it has become convenient to maintain repos up to a point. But how can you extend these repos?



Up to now, you can build an image of a specific tag using the --target in the docker build command.



From docker-compose, you can use the target entry in the context entry to specify it.



In my case, I want to use an image from docker hub and extend a specific target.
Right now, I am using a Dockerfile (which I call from docker-compose but that shouldn't matter) which has the



FROM repo/sample-name
DO my stuff


That repo has 3 targets in their Dockerfile named sample-name, sample-name-full which extends sample-name and sample-name-dev which extends sample-name-full. The dashes in these names are just like the repo named their targets.



What seems to be happening is that I am getting the first target as the build target (or I think I do) which is named after the repo itself. How can I, let's say, extend the intermediate target?



I tried stuff like



FROM repo/sample-name:latest-sample-name-dev


etc but I could not make it work.










share|improve this question





























    0















    With the support of the multi-stage builds, it has become convenient to maintain repos up to a point. But how can you extend these repos?



    Up to now, you can build an image of a specific tag using the --target in the docker build command.



    From docker-compose, you can use the target entry in the context entry to specify it.



    In my case, I want to use an image from docker hub and extend a specific target.
    Right now, I am using a Dockerfile (which I call from docker-compose but that shouldn't matter) which has the



    FROM repo/sample-name
    DO my stuff


    That repo has 3 targets in their Dockerfile named sample-name, sample-name-full which extends sample-name and sample-name-dev which extends sample-name-full. The dashes in these names are just like the repo named their targets.



    What seems to be happening is that I am getting the first target as the build target (or I think I do) which is named after the repo itself. How can I, let's say, extend the intermediate target?



    I tried stuff like



    FROM repo/sample-name:latest-sample-name-dev


    etc but I could not make it work.










    share|improve this question



























      0












      0








      0








      With the support of the multi-stage builds, it has become convenient to maintain repos up to a point. But how can you extend these repos?



      Up to now, you can build an image of a specific tag using the --target in the docker build command.



      From docker-compose, you can use the target entry in the context entry to specify it.



      In my case, I want to use an image from docker hub and extend a specific target.
      Right now, I am using a Dockerfile (which I call from docker-compose but that shouldn't matter) which has the



      FROM repo/sample-name
      DO my stuff


      That repo has 3 targets in their Dockerfile named sample-name, sample-name-full which extends sample-name and sample-name-dev which extends sample-name-full. The dashes in these names are just like the repo named their targets.



      What seems to be happening is that I am getting the first target as the build target (or I think I do) which is named after the repo itself. How can I, let's say, extend the intermediate target?



      I tried stuff like



      FROM repo/sample-name:latest-sample-name-dev


      etc but I could not make it work.










      share|improve this question
















      With the support of the multi-stage builds, it has become convenient to maintain repos up to a point. But how can you extend these repos?



      Up to now, you can build an image of a specific tag using the --target in the docker build command.



      From docker-compose, you can use the target entry in the context entry to specify it.



      In my case, I want to use an image from docker hub and extend a specific target.
      Right now, I am using a Dockerfile (which I call from docker-compose but that shouldn't matter) which has the



      FROM repo/sample-name
      DO my stuff


      That repo has 3 targets in their Dockerfile named sample-name, sample-name-full which extends sample-name and sample-name-dev which extends sample-name-full. The dashes in these names are just like the repo named their targets.



      What seems to be happening is that I am getting the first target as the build target (or I think I do) which is named after the repo itself. How can I, let's say, extend the intermediate target?



      I tried stuff like



      FROM repo/sample-name:latest-sample-name-dev


      etc but I could not make it work.







      docker dockerfile docker-multi-stage-build






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 27 '18 at 13:04









      Siyu

      2,91411227




      2,91411227










      asked Nov 27 '18 at 7:41









      I. DimopoulosI. Dimopoulos

      31




      31
























          1 Answer
          1






          active

          oldest

          votes


















          0














          This is not possible by design. One advantage of the multi-stage build is to hide intermediate stage, an example could be to download something with hard coded credentials in the first stage and then in the second stage copy the result from it. The final image, as is available on the dockerhub, is ostensibly single-stage built. Most the time you won't worry about this as the final stage has acquired all useful things from previous ones.






          share|improve this answer


























          • So this means that what is downloaded from docker hub is an image that contains all stages, right?

            – I. Dimopoulos
            Nov 27 '18 at 14:34











          • @I.Dimopoulos it contains all layers from the last stage and some layers were built with the help of previous stages. You really don’t see previous stages, a ‘copy —from stage’ is no different than a normal copy.

            – Siyu
            Nov 27 '18 at 14:38











          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',
          autoActivateHeartbeat: false,
          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%2f53494880%2fextend-a-stage-of-multi-stage-built-image-on-docker-hub%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          This is not possible by design. One advantage of the multi-stage build is to hide intermediate stage, an example could be to download something with hard coded credentials in the first stage and then in the second stage copy the result from it. The final image, as is available on the dockerhub, is ostensibly single-stage built. Most the time you won't worry about this as the final stage has acquired all useful things from previous ones.






          share|improve this answer


























          • So this means that what is downloaded from docker hub is an image that contains all stages, right?

            – I. Dimopoulos
            Nov 27 '18 at 14:34











          • @I.Dimopoulos it contains all layers from the last stage and some layers were built with the help of previous stages. You really don’t see previous stages, a ‘copy —from stage’ is no different than a normal copy.

            – Siyu
            Nov 27 '18 at 14:38
















          0














          This is not possible by design. One advantage of the multi-stage build is to hide intermediate stage, an example could be to download something with hard coded credentials in the first stage and then in the second stage copy the result from it. The final image, as is available on the dockerhub, is ostensibly single-stage built. Most the time you won't worry about this as the final stage has acquired all useful things from previous ones.






          share|improve this answer


























          • So this means that what is downloaded from docker hub is an image that contains all stages, right?

            – I. Dimopoulos
            Nov 27 '18 at 14:34











          • @I.Dimopoulos it contains all layers from the last stage and some layers were built with the help of previous stages. You really don’t see previous stages, a ‘copy —from stage’ is no different than a normal copy.

            – Siyu
            Nov 27 '18 at 14:38














          0












          0








          0







          This is not possible by design. One advantage of the multi-stage build is to hide intermediate stage, an example could be to download something with hard coded credentials in the first stage and then in the second stage copy the result from it. The final image, as is available on the dockerhub, is ostensibly single-stage built. Most the time you won't worry about this as the final stage has acquired all useful things from previous ones.






          share|improve this answer















          This is not possible by design. One advantage of the multi-stage build is to hide intermediate stage, an example could be to download something with hard coded credentials in the first stage and then in the second stage copy the result from it. The final image, as is available on the dockerhub, is ostensibly single-stage built. Most the time you won't worry about this as the final stage has acquired all useful things from previous ones.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 6 at 14:58

























          answered Nov 27 '18 at 11:05









          SiyuSiyu

          2,91411227




          2,91411227













          • So this means that what is downloaded from docker hub is an image that contains all stages, right?

            – I. Dimopoulos
            Nov 27 '18 at 14:34











          • @I.Dimopoulos it contains all layers from the last stage and some layers were built with the help of previous stages. You really don’t see previous stages, a ‘copy —from stage’ is no different than a normal copy.

            – Siyu
            Nov 27 '18 at 14:38



















          • So this means that what is downloaded from docker hub is an image that contains all stages, right?

            – I. Dimopoulos
            Nov 27 '18 at 14:34











          • @I.Dimopoulos it contains all layers from the last stage and some layers were built with the help of previous stages. You really don’t see previous stages, a ‘copy —from stage’ is no different than a normal copy.

            – Siyu
            Nov 27 '18 at 14:38

















          So this means that what is downloaded from docker hub is an image that contains all stages, right?

          – I. Dimopoulos
          Nov 27 '18 at 14:34





          So this means that what is downloaded from docker hub is an image that contains all stages, right?

          – I. Dimopoulos
          Nov 27 '18 at 14:34













          @I.Dimopoulos it contains all layers from the last stage and some layers were built with the help of previous stages. You really don’t see previous stages, a ‘copy —from stage’ is no different than a normal copy.

          – Siyu
          Nov 27 '18 at 14:38





          @I.Dimopoulos it contains all layers from the last stage and some layers were built with the help of previous stages. You really don’t see previous stages, a ‘copy —from stage’ is no different than a normal copy.

          – Siyu
          Nov 27 '18 at 14:38




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53494880%2fextend-a-stage-of-multi-stage-built-image-on-docker-hub%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

          Calculate evaluation metrics using cross_val_predict sklearn

          Insert data from modal to MySQL (multiple modal on website)