How to loop for 3 times in bash script when docker push fails?For Loop for Google Image Downloading Bash ScriptHow can I get this script to error exit based on result of for loop?Bash For Loop - prompt for IP range and passwordfor loop in bashHow do you create a for loop with a changeable number of iterations?Collect awk output in bash script for processingHow to convert an input parameter to integer value in a for loop in bash?line continuation when using docker exec bash with double quotesRun script for 10 times or until it meets the conditionbash for loop multiple number ranges

During copyediting, journal disagrees about spelling of paper's main topic

Find The One Element In An Array That is Different From The Others

Is the genetic term "polycistronic" still used in modern biology?

What steps should I take to lawfully visit the United States as a tourist immediately after visiting on a B-1 visa?

How to convert a file with several spaces into a tab-delimited file?

Print the last, middle and first character of your code

Why do people keep referring to Leia as Princess Leia, even after the destruction of Alderaan?

Single word for "refusing to move to next activity unless present one is completed."

What explains 9 speed cassettes price differences?

What's the minimum number of sensors for a hobby GPS waypoint-following UAV?

Referring to different instances of the same character in time travel

0x0000000000000000000000000000000000000000 address behaviour

What prevents someone from claiming to be the murderer in order to get the real murderer off?

How to memorize multiple pieces?

Why isn't there research to build a standard lunar, or Martian mobility platform?

Credit score and financing new car

Why didn't Nick Fury expose the villain's identity and plans?

How would vampires avoid contracting diseases?

Are there any medieval light sources without fire?

definition of "percentile"

Keep milk (or milk alternative) for a day without a fridge

Is there any word for "disobedience to God"?

How to evolve human-like eyes that can stare at the sun without protection?

Confirming the Identity of a (Friendly) Reviewer After the Reviews



How to loop for 3 times in bash script when docker push fails?


For Loop for Google Image Downloading Bash ScriptHow can I get this script to error exit based on result of for loop?Bash For Loop - prompt for IP range and passwordfor loop in bashHow do you create a for loop with a changeable number of iterations?Collect awk output in bash script for processingHow to convert an input parameter to integer value in a for loop in bash?line continuation when using docker exec bash with double quotesRun script for 10 times or until it meets the conditionbash for loop multiple number ranges






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I have a bash script that I simply docker push an image:



docker push $CONTAINER_IMAGE:latest


I want to loop for 3 times when docker push fails. How should I achieve this?










share|improve this question






























    2















    I have a bash script that I simply docker push an image:



    docker push $CONTAINER_IMAGE:latest


    I want to loop for 3 times when docker push fails. How should I achieve this?










    share|improve this question


























      2












      2








      2








      I have a bash script that I simply docker push an image:



      docker push $CONTAINER_IMAGE:latest


      I want to loop for 3 times when docker push fails. How should I achieve this?










      share|improve this question
















      I have a bash script that I simply docker push an image:



      docker push $CONTAINER_IMAGE:latest


      I want to loop for 3 times when docker push fails. How should I achieve this?







      bash docker for exit-status






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 8 hours ago







      ALH

















      asked 9 hours ago









      ALHALH

      2072 silver badges12 bronze badges




      2072 silver badges12 bronze badges




















          2 Answers
          2






          active

          oldest

          votes


















          7














          Use for-loop and && break:



          for n in 1..3; do
          docker push $CONTAINER_IMAGE:latest && break;
          done


          break quits the loop, but only runs when docker push succeeded. If docker push fails, it will exit with error and the loop will continue.






          share|improve this answer






























            1














            You can also use :



            for n in 1..3; do
            if docker push $CONTAINER_IMAGE:latest
            then
            break;
            fi
            done


            The then statement will be entered only if the docker command succeeds.






            share|improve this answer










            New contributor



            arna is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.














            • 1





              Need to close the if statement with fi

              – L. Scott Johnson
              7 hours ago











            • Edited. Thanks !

              – arna
              7 hours ago













            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            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: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            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%2funix.stackexchange.com%2fquestions%2f529379%2fhow-to-loop-for-3-times-in-bash-script-when-docker-push-fails%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









            7














            Use for-loop and && break:



            for n in 1..3; do
            docker push $CONTAINER_IMAGE:latest && break;
            done


            break quits the loop, but only runs when docker push succeeded. If docker push fails, it will exit with error and the loop will continue.






            share|improve this answer



























              7














              Use for-loop and && break:



              for n in 1..3; do
              docker push $CONTAINER_IMAGE:latest && break;
              done


              break quits the loop, but only runs when docker push succeeded. If docker push fails, it will exit with error and the loop will continue.






              share|improve this answer

























                7












                7








                7







                Use for-loop and && break:



                for n in 1..3; do
                docker push $CONTAINER_IMAGE:latest && break;
                done


                break quits the loop, but only runs when docker push succeeded. If docker push fails, it will exit with error and the loop will continue.






                share|improve this answer













                Use for-loop and && break:



                for n in 1..3; do
                docker push $CONTAINER_IMAGE:latest && break;
                done


                break quits the loop, but only runs when docker push succeeded. If docker push fails, it will exit with error and the loop will continue.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 9 hours ago









                pLumopLumo

                6,45712 silver badges26 bronze badges




                6,45712 silver badges26 bronze badges























                    1














                    You can also use :



                    for n in 1..3; do
                    if docker push $CONTAINER_IMAGE:latest
                    then
                    break;
                    fi
                    done


                    The then statement will be entered only if the docker command succeeds.






                    share|improve this answer










                    New contributor



                    arna is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.














                    • 1





                      Need to close the if statement with fi

                      – L. Scott Johnson
                      7 hours ago











                    • Edited. Thanks !

                      – arna
                      7 hours ago















                    1














                    You can also use :



                    for n in 1..3; do
                    if docker push $CONTAINER_IMAGE:latest
                    then
                    break;
                    fi
                    done


                    The then statement will be entered only if the docker command succeeds.






                    share|improve this answer










                    New contributor



                    arna is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.














                    • 1





                      Need to close the if statement with fi

                      – L. Scott Johnson
                      7 hours ago











                    • Edited. Thanks !

                      – arna
                      7 hours ago













                    1












                    1








                    1







                    You can also use :



                    for n in 1..3; do
                    if docker push $CONTAINER_IMAGE:latest
                    then
                    break;
                    fi
                    done


                    The then statement will be entered only if the docker command succeeds.






                    share|improve this answer










                    New contributor



                    arna is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.









                    You can also use :



                    for n in 1..3; do
                    if docker push $CONTAINER_IMAGE:latest
                    then
                    break;
                    fi
                    done


                    The then statement will be entered only if the docker command succeeds.







                    share|improve this answer










                    New contributor



                    arna is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.








                    share|improve this answer



                    share|improve this answer








                    edited 7 hours ago





















                    New contributor



                    arna is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.








                    answered 8 hours ago









                    arnaarna

                    112 bronze badges




                    112 bronze badges




                    New contributor



                    arna is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.




                    New contributor




                    arna is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.









                    • 1





                      Need to close the if statement with fi

                      – L. Scott Johnson
                      7 hours ago











                    • Edited. Thanks !

                      – arna
                      7 hours ago












                    • 1





                      Need to close the if statement with fi

                      – L. Scott Johnson
                      7 hours ago











                    • Edited. Thanks !

                      – arna
                      7 hours ago







                    1




                    1





                    Need to close the if statement with fi

                    – L. Scott Johnson
                    7 hours ago





                    Need to close the if statement with fi

                    – L. Scott Johnson
                    7 hours ago













                    Edited. Thanks !

                    – arna
                    7 hours ago





                    Edited. Thanks !

                    – arna
                    7 hours ago

















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • 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%2funix.stackexchange.com%2fquestions%2f529379%2fhow-to-loop-for-3-times-in-bash-script-when-docker-push-fails%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

                    Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                    Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                    François Viète Contents Biography Work and thought Bibliography See also Notes Further reading External links Navigation menup. 21Google Bookspp. 75–77Google BooksDe thou (from University of Saint Andrews)ArchivedGoogle BooksGoogle BooksGoogle BooksGoogle booksGoogle Bookscc-parthenay.frL'histoire universelle (fr)Universal History (en)ArchivedAdsabs.harvard.eduPagesperso-orange.frArchive.orgChikara Sasaki. Descartes' mathematical thought p.259Google BooksGoogle BooksGoogle Bookspp. 152 and onwardGoogle BooksGoogle BooksScribd.comGoogle Books1257-7979Google BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGallica.bnf.frGoogle BooksGoogle Books"François Viète"Francois Viète: Father of Modern Algebraic NotationThe Lawyer and the GamblerAbout TarporleySite de Jean-Paul GuichardL'algèbre nouvelle"About the Harmonicon"cb120511976(data)1188044800000 0001 0913 5903n82164680ola2013766880073431702w6vt1sb70287374827140948071409480