Continue building Docker image after error occured












1















I have a Dockerfile that install Ubuntu and some packages over it and then proceeds to use these packages. Let's say I need to run 'wget' command, but forgot to issue install of the 'wget' package. I add the package to install command and continue with my execution. However I have to start over - install Ubuntu, install package, etc., or do I? Is there ability to save what I did until error occurred and continue from that point after I did my fixes instead of downloading everything again?










share|improve this question


















  • 1





    Sometimes for this instance you might want to subdivide your build into a sequence of images. Each successive step picks up the previous step at the FROM command.

    – Richard Barber
    Jan 2 at 0:14











  • If you re-run docker build it will essentially skip over steps it's already done. See for example "Leverage build cache" in "Best practices for writing Dockerfiles" in the Docker documentation.

    – David Maze
    Jan 2 at 0:38











  • @DavidMaze That's interesting because it looks like every time I build my docker, it's starts fresh. May be I am not issues enough commands? As I understand cache is automatic. Here is my Dockerfile github.com/akravets/bus-notify/blob/master/Dockerfile

    – Alex Kravets
    Jan 2 at 3:12











  • Any time anything changes, none of the later steps will be cached. Since you have COPY . /camera very early in the Dockerfile, the following RUN apt-get ... becomes non-cacheable if anything changes at all in your source tree. I'd move that to later.

    – David Maze
    Jan 2 at 10:30











  • Thank you David

    – Alex Kravets
    Jan 2 at 11:51
















1















I have a Dockerfile that install Ubuntu and some packages over it and then proceeds to use these packages. Let's say I need to run 'wget' command, but forgot to issue install of the 'wget' package. I add the package to install command and continue with my execution. However I have to start over - install Ubuntu, install package, etc., or do I? Is there ability to save what I did until error occurred and continue from that point after I did my fixes instead of downloading everything again?










share|improve this question


















  • 1





    Sometimes for this instance you might want to subdivide your build into a sequence of images. Each successive step picks up the previous step at the FROM command.

    – Richard Barber
    Jan 2 at 0:14











  • If you re-run docker build it will essentially skip over steps it's already done. See for example "Leverage build cache" in "Best practices for writing Dockerfiles" in the Docker documentation.

    – David Maze
    Jan 2 at 0:38











  • @DavidMaze That's interesting because it looks like every time I build my docker, it's starts fresh. May be I am not issues enough commands? As I understand cache is automatic. Here is my Dockerfile github.com/akravets/bus-notify/blob/master/Dockerfile

    – Alex Kravets
    Jan 2 at 3:12











  • Any time anything changes, none of the later steps will be cached. Since you have COPY . /camera very early in the Dockerfile, the following RUN apt-get ... becomes non-cacheable if anything changes at all in your source tree. I'd move that to later.

    – David Maze
    Jan 2 at 10:30











  • Thank you David

    – Alex Kravets
    Jan 2 at 11:51














1












1








1


1






I have a Dockerfile that install Ubuntu and some packages over it and then proceeds to use these packages. Let's say I need to run 'wget' command, but forgot to issue install of the 'wget' package. I add the package to install command and continue with my execution. However I have to start over - install Ubuntu, install package, etc., or do I? Is there ability to save what I did until error occurred and continue from that point after I did my fixes instead of downloading everything again?










share|improve this question














I have a Dockerfile that install Ubuntu and some packages over it and then proceeds to use these packages. Let's say I need to run 'wget' command, but forgot to issue install of the 'wget' package. I add the package to install command and continue with my execution. However I have to start over - install Ubuntu, install package, etc., or do I? Is there ability to save what I did until error occurred and continue from that point after I did my fixes instead of downloading everything again?







docker






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 1 at 22:54









Alex KravetsAlex Kravets

1,86221217




1,86221217








  • 1





    Sometimes for this instance you might want to subdivide your build into a sequence of images. Each successive step picks up the previous step at the FROM command.

    – Richard Barber
    Jan 2 at 0:14











  • If you re-run docker build it will essentially skip over steps it's already done. See for example "Leverage build cache" in "Best practices for writing Dockerfiles" in the Docker documentation.

    – David Maze
    Jan 2 at 0:38











  • @DavidMaze That's interesting because it looks like every time I build my docker, it's starts fresh. May be I am not issues enough commands? As I understand cache is automatic. Here is my Dockerfile github.com/akravets/bus-notify/blob/master/Dockerfile

    – Alex Kravets
    Jan 2 at 3:12











  • Any time anything changes, none of the later steps will be cached. Since you have COPY . /camera very early in the Dockerfile, the following RUN apt-get ... becomes non-cacheable if anything changes at all in your source tree. I'd move that to later.

    – David Maze
    Jan 2 at 10:30











  • Thank you David

    – Alex Kravets
    Jan 2 at 11:51














  • 1





    Sometimes for this instance you might want to subdivide your build into a sequence of images. Each successive step picks up the previous step at the FROM command.

    – Richard Barber
    Jan 2 at 0:14











  • If you re-run docker build it will essentially skip over steps it's already done. See for example "Leverage build cache" in "Best practices for writing Dockerfiles" in the Docker documentation.

    – David Maze
    Jan 2 at 0:38











  • @DavidMaze That's interesting because it looks like every time I build my docker, it's starts fresh. May be I am not issues enough commands? As I understand cache is automatic. Here is my Dockerfile github.com/akravets/bus-notify/blob/master/Dockerfile

    – Alex Kravets
    Jan 2 at 3:12











  • Any time anything changes, none of the later steps will be cached. Since you have COPY . /camera very early in the Dockerfile, the following RUN apt-get ... becomes non-cacheable if anything changes at all in your source tree. I'd move that to later.

    – David Maze
    Jan 2 at 10:30











  • Thank you David

    – Alex Kravets
    Jan 2 at 11:51








1




1





Sometimes for this instance you might want to subdivide your build into a sequence of images. Each successive step picks up the previous step at the FROM command.

– Richard Barber
Jan 2 at 0:14





Sometimes for this instance you might want to subdivide your build into a sequence of images. Each successive step picks up the previous step at the FROM command.

– Richard Barber
Jan 2 at 0:14













If you re-run docker build it will essentially skip over steps it's already done. See for example "Leverage build cache" in "Best practices for writing Dockerfiles" in the Docker documentation.

– David Maze
Jan 2 at 0:38





If you re-run docker build it will essentially skip over steps it's already done. See for example "Leverage build cache" in "Best practices for writing Dockerfiles" in the Docker documentation.

– David Maze
Jan 2 at 0:38













@DavidMaze That's interesting because it looks like every time I build my docker, it's starts fresh. May be I am not issues enough commands? As I understand cache is automatic. Here is my Dockerfile github.com/akravets/bus-notify/blob/master/Dockerfile

– Alex Kravets
Jan 2 at 3:12





@DavidMaze That's interesting because it looks like every time I build my docker, it's starts fresh. May be I am not issues enough commands? As I understand cache is automatic. Here is my Dockerfile github.com/akravets/bus-notify/blob/master/Dockerfile

– Alex Kravets
Jan 2 at 3:12













Any time anything changes, none of the later steps will be cached. Since you have COPY . /camera very early in the Dockerfile, the following RUN apt-get ... becomes non-cacheable if anything changes at all in your source tree. I'd move that to later.

– David Maze
Jan 2 at 10:30





Any time anything changes, none of the later steps will be cached. Since you have COPY . /camera very early in the Dockerfile, the following RUN apt-get ... becomes non-cacheable if anything changes at all in your source tree. I'd move that to later.

– David Maze
Jan 2 at 10:30













Thank you David

– Alex Kravets
Jan 2 at 11:51





Thank you David

– Alex Kravets
Jan 2 at 11:51












2 Answers
2






active

oldest

votes


















2














Sometimes for this instance you might want to subdivide your build into a chain of images. Each successive step picks up the previous step at the FROM command.






share|improve this answer































    0














    Just to point out that David Maze's answer was most appropriate for my case:




    Any time anything changes, none of the later steps will be cached. Since you have COPY . /camera very early in the Dockerfile, the following RUN apt-get ... becomes non-cacheable if anything changes at all in your source tree. I'd move that to later.




    This is what I had COPY command in a wrong place, which really makes sense - I copy everything docker accumulated before resolving what I needed so I ended executing all directives after COPY every time I build the image. After I moved COPY down as David suggested, all the cached data was there.






    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',
      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%2f53999573%2fcontinue-building-docker-image-after-error-occured%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









      2














      Sometimes for this instance you might want to subdivide your build into a chain of images. Each successive step picks up the previous step at the FROM command.






      share|improve this answer




























        2














        Sometimes for this instance you might want to subdivide your build into a chain of images. Each successive step picks up the previous step at the FROM command.






        share|improve this answer


























          2












          2








          2







          Sometimes for this instance you might want to subdivide your build into a chain of images. Each successive step picks up the previous step at the FROM command.






          share|improve this answer













          Sometimes for this instance you might want to subdivide your build into a chain of images. Each successive step picks up the previous step at the FROM command.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 2 at 1:29









          Richard BarberRichard Barber

          26316




          26316

























              0














              Just to point out that David Maze's answer was most appropriate for my case:




              Any time anything changes, none of the later steps will be cached. Since you have COPY . /camera very early in the Dockerfile, the following RUN apt-get ... becomes non-cacheable if anything changes at all in your source tree. I'd move that to later.




              This is what I had COPY command in a wrong place, which really makes sense - I copy everything docker accumulated before resolving what I needed so I ended executing all directives after COPY every time I build the image. After I moved COPY down as David suggested, all the cached data was there.






              share|improve this answer




























                0














                Just to point out that David Maze's answer was most appropriate for my case:




                Any time anything changes, none of the later steps will be cached. Since you have COPY . /camera very early in the Dockerfile, the following RUN apt-get ... becomes non-cacheable if anything changes at all in your source tree. I'd move that to later.




                This is what I had COPY command in a wrong place, which really makes sense - I copy everything docker accumulated before resolving what I needed so I ended executing all directives after COPY every time I build the image. After I moved COPY down as David suggested, all the cached data was there.






                share|improve this answer


























                  0












                  0








                  0







                  Just to point out that David Maze's answer was most appropriate for my case:




                  Any time anything changes, none of the later steps will be cached. Since you have COPY . /camera very early in the Dockerfile, the following RUN apt-get ... becomes non-cacheable if anything changes at all in your source tree. I'd move that to later.




                  This is what I had COPY command in a wrong place, which really makes sense - I copy everything docker accumulated before resolving what I needed so I ended executing all directives after COPY every time I build the image. After I moved COPY down as David suggested, all the cached data was there.






                  share|improve this answer













                  Just to point out that David Maze's answer was most appropriate for my case:




                  Any time anything changes, none of the later steps will be cached. Since you have COPY . /camera very early in the Dockerfile, the following RUN apt-get ... becomes non-cacheable if anything changes at all in your source tree. I'd move that to later.




                  This is what I had COPY command in a wrong place, which really makes sense - I copy everything docker accumulated before resolving what I needed so I ended executing all directives after COPY every time I build the image. After I moved COPY down as David suggested, all the cached data was there.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 2 at 18:53









                  Alex KravetsAlex Kravets

                  1,86221217




                  1,86221217






























                      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%2f53999573%2fcontinue-building-docker-image-after-error-occured%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

                      'app-layout' is not a known element: how to share Component with different Modules

                      android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

                      WPF add header to Image with URL pettitions [duplicate]