I am somewhat new to docker, and trying to understand why && and || mean in dockerfile RUN command. Is there a documentation that explains how they work?
Asked
Active
Viewed 3,711 times
1
-
3Assuming you have unix based image, it means the same as in any shell script ... – derpirscher Feb 18 '22 at 16:53
-
Possible duplicate: https://stackoverflow.com/q/4510640/596285 – BMitch Feb 18 '22 at 16:55
-
What about Windows images? – Alex I Feb 18 '22 at 16:58
-
It is not only about bash scripting but also efficiency of docker image. See https://stackoverflow.com/q/39223249/12501050 – m19v Feb 18 '22 at 16:59
1 Answers
3
These are standard Bourne shell script operators. In short: the code after each &&
will be evaluated only if part before these symbols is finished with exit code 0 (i.e., successfully). ||
is exactly the opposite, in that the code after it will be evaluated only if what was before the symbols finished with a non-zero exit code (i.e., failed).

David Maze
- 130,717
- 29
- 175
- 215

Max Skoryk
- 404
- 2
- 10
-
-
Don't have much experience with the Windows command line, but the operators behave the same according to multiple sources. E.g., https://en.wikibooks.org/wiki/Windows_Batch_Scripting – Max Skoryk Feb 18 '22 at 22:30