Build docker image from layers











up vote
0
down vote

favorite












I have a big docker image I need to copy to a remote machine.
I build the image on my local machine with an unchanging base image, so only the last few layers change.
I would like to have that base image on the remote machine and only copy the changed top layers to the remote machine whenever they change. I cannot build the image on the remote using its dockerfile because the necessary source files are not present on the remote.



I can separate the image into its layers using undocker, but how do I reassemble the image from its layers on the remote machine?










share|improve this question


















  • 1




    why you done push your image to dockerhub then acces to remote server and pull it ?
    – Truong Dang
    Nov 8 at 7:32










  • If you really don't have a registry available, I wonder if it would work to docker save the image, unpack the tarball, rsync that to the remote system, rebuild the tarball, and docker load the result. That won't be fast in Docker time, but it would probably save network I/O.
    – David Maze
    Nov 8 at 11:11















up vote
0
down vote

favorite












I have a big docker image I need to copy to a remote machine.
I build the image on my local machine with an unchanging base image, so only the last few layers change.
I would like to have that base image on the remote machine and only copy the changed top layers to the remote machine whenever they change. I cannot build the image on the remote using its dockerfile because the necessary source files are not present on the remote.



I can separate the image into its layers using undocker, but how do I reassemble the image from its layers on the remote machine?










share|improve this question


















  • 1




    why you done push your image to dockerhub then acces to remote server and pull it ?
    – Truong Dang
    Nov 8 at 7:32










  • If you really don't have a registry available, I wonder if it would work to docker save the image, unpack the tarball, rsync that to the remote system, rebuild the tarball, and docker load the result. That won't be fast in Docker time, but it would probably save network I/O.
    – David Maze
    Nov 8 at 11:11













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a big docker image I need to copy to a remote machine.
I build the image on my local machine with an unchanging base image, so only the last few layers change.
I would like to have that base image on the remote machine and only copy the changed top layers to the remote machine whenever they change. I cannot build the image on the remote using its dockerfile because the necessary source files are not present on the remote.



I can separate the image into its layers using undocker, but how do I reassemble the image from its layers on the remote machine?










share|improve this question













I have a big docker image I need to copy to a remote machine.
I build the image on my local machine with an unchanging base image, so only the last few layers change.
I would like to have that base image on the remote machine and only copy the changed top layers to the remote machine whenever they change. I cannot build the image on the remote using its dockerfile because the necessary source files are not present on the remote.



I can separate the image into its layers using undocker, but how do I reassemble the image from its layers on the remote machine?







docker






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 8 at 7:17









warakawa

351413




351413








  • 1




    why you done push your image to dockerhub then acces to remote server and pull it ?
    – Truong Dang
    Nov 8 at 7:32










  • If you really don't have a registry available, I wonder if it would work to docker save the image, unpack the tarball, rsync that to the remote system, rebuild the tarball, and docker load the result. That won't be fast in Docker time, but it would probably save network I/O.
    – David Maze
    Nov 8 at 11:11














  • 1




    why you done push your image to dockerhub then acces to remote server and pull it ?
    – Truong Dang
    Nov 8 at 7:32










  • If you really don't have a registry available, I wonder if it would work to docker save the image, unpack the tarball, rsync that to the remote system, rebuild the tarball, and docker load the result. That won't be fast in Docker time, but it would probably save network I/O.
    – David Maze
    Nov 8 at 11:11








1




1




why you done push your image to dockerhub then acces to remote server and pull it ?
– Truong Dang
Nov 8 at 7:32




why you done push your image to dockerhub then acces to remote server and pull it ?
– Truong Dang
Nov 8 at 7:32












If you really don't have a registry available, I wonder if it would work to docker save the image, unpack the tarball, rsync that to the remote system, rebuild the tarball, and docker load the result. That won't be fast in Docker time, but it would probably save network I/O.
– David Maze
Nov 8 at 11:11




If you really don't have a registry available, I wonder if it would work to docker save the image, unpack the tarball, rsync that to the remote system, rebuild the tarball, and docker load the result. That won't be fast in Docker time, but it would probably save network I/O.
– David Maze
Nov 8 at 11:11












2 Answers
2






active

oldest

votes

















up vote
0
down vote













I've never worked with undocker tool so I can't comment on this, but in my understanding image in docker is a "sealed package" ready for distribution in one way or another.



So copying part of the image sounds to me like distributing a part of the package.



I can understand that overhead of big image on the other hand (probably you're looking for faster copying), but it contradicts the docker "ideology" (take image "as is" and work with it)



So, probably the most straightforward option is preparing the sources (those are in the "last few layers") as a distributable package without docker, copying them to the remote machine and then building the image on the remote machine out of a base image and this distributable package



This allows overcoming a workaround of "the necessary source files are not present on the remote" as you say






share|improve this answer




























    up vote
    0
    down vote



    accepted










    I have switched to using a Docker registry, and updating my image with docker pull, which I think is the proper way to solve this problem, since it will only download the changed layers.
    This article also helped me reduce the size of my images.






    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%2f53203000%2fbuild-docker-image-from-layers%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      0
      down vote













      I've never worked with undocker tool so I can't comment on this, but in my understanding image in docker is a "sealed package" ready for distribution in one way or another.



      So copying part of the image sounds to me like distributing a part of the package.



      I can understand that overhead of big image on the other hand (probably you're looking for faster copying), but it contradicts the docker "ideology" (take image "as is" and work with it)



      So, probably the most straightforward option is preparing the sources (those are in the "last few layers") as a distributable package without docker, copying them to the remote machine and then building the image on the remote machine out of a base image and this distributable package



      This allows overcoming a workaround of "the necessary source files are not present on the remote" as you say






      share|improve this answer

























        up vote
        0
        down vote













        I've never worked with undocker tool so I can't comment on this, but in my understanding image in docker is a "sealed package" ready for distribution in one way or another.



        So copying part of the image sounds to me like distributing a part of the package.



        I can understand that overhead of big image on the other hand (probably you're looking for faster copying), but it contradicts the docker "ideology" (take image "as is" and work with it)



        So, probably the most straightforward option is preparing the sources (those are in the "last few layers") as a distributable package without docker, copying them to the remote machine and then building the image on the remote machine out of a base image and this distributable package



        This allows overcoming a workaround of "the necessary source files are not present on the remote" as you say






        share|improve this answer























          up vote
          0
          down vote










          up vote
          0
          down vote









          I've never worked with undocker tool so I can't comment on this, but in my understanding image in docker is a "sealed package" ready for distribution in one way or another.



          So copying part of the image sounds to me like distributing a part of the package.



          I can understand that overhead of big image on the other hand (probably you're looking for faster copying), but it contradicts the docker "ideology" (take image "as is" and work with it)



          So, probably the most straightforward option is preparing the sources (those are in the "last few layers") as a distributable package without docker, copying them to the remote machine and then building the image on the remote machine out of a base image and this distributable package



          This allows overcoming a workaround of "the necessary source files are not present on the remote" as you say






          share|improve this answer












          I've never worked with undocker tool so I can't comment on this, but in my understanding image in docker is a "sealed package" ready for distribution in one way or another.



          So copying part of the image sounds to me like distributing a part of the package.



          I can understand that overhead of big image on the other hand (probably you're looking for faster copying), but it contradicts the docker "ideology" (take image "as is" and work with it)



          So, probably the most straightforward option is preparing the sources (those are in the "last few layers") as a distributable package without docker, copying them to the remote machine and then building the image on the remote machine out of a base image and this distributable package



          This allows overcoming a workaround of "the necessary source files are not present on the remote" as you say







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 8 at 7:31









          Mark Bramnik

          11.2k32445




          11.2k32445
























              up vote
              0
              down vote



              accepted










              I have switched to using a Docker registry, and updating my image with docker pull, which I think is the proper way to solve this problem, since it will only download the changed layers.
              This article also helped me reduce the size of my images.






              share|improve this answer

























                up vote
                0
                down vote



                accepted










                I have switched to using a Docker registry, and updating my image with docker pull, which I think is the proper way to solve this problem, since it will only download the changed layers.
                This article also helped me reduce the size of my images.






                share|improve this answer























                  up vote
                  0
                  down vote



                  accepted







                  up vote
                  0
                  down vote



                  accepted






                  I have switched to using a Docker registry, and updating my image with docker pull, which I think is the proper way to solve this problem, since it will only download the changed layers.
                  This article also helped me reduce the size of my images.






                  share|improve this answer












                  I have switched to using a Docker registry, and updating my image with docker pull, which I think is the proper way to solve this problem, since it will only download the changed layers.
                  This article also helped me reduce the size of my images.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 29 at 6:00









                  warakawa

                  351413




                  351413






























                      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.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • 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%2f53203000%2fbuild-docker-image-from-layers%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







                      這個網誌中的熱門文章

                      Xamarin.form Move up view when keyboard appear

                      Post-Redirect-Get with Spring WebFlux and Thymeleaf

                      Anylogic : not able to use stopDelay()