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;
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
add a comment |
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
add a comment |
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
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
bash docker for exit-status
edited 8 hours ago
ALH
asked 9 hours ago
ALHALH
2072 silver badges12 bronze badges
2072 silver badges12 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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.
add a comment |
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.
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 withfi
– L. Scott Johnson
7 hours ago
Edited. Thanks !
– arna
7 hours ago
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
answered 9 hours ago
pLumopLumo
6,45712 silver badges26 bronze badges
6,45712 silver badges26 bronze badges
add a comment |
add a comment |
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.
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 withfi
– L. Scott Johnson
7 hours ago
Edited. Thanks !
– arna
7 hours ago
add a comment |
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.
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 withfi
– L. Scott Johnson
7 hours ago
Edited. Thanks !
– arna
7 hours ago
add a comment |
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.
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.
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.
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 withfi
– L. Scott Johnson
7 hours ago
Edited. Thanks !
– arna
7 hours ago
add a comment |
1
Need to close the if statement withfi
– 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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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