I would like references on how to check the exit code from docker command like docker run
, docker build
etc. in a windows batch file.
Asked
Active
Viewed 839 times
0

double-beep
- 5,031
- 17
- 33
- 41

Chubsdad
- 24,777
- 4
- 73
- 129
-
Possible duplicate of [Get error code from within a batch file](https://stackoverflow.com/questions/3452046/get-error-code-from-within-a-batch-file) – jonrsharpe Mar 15 '19 at 15:45
-
`if %errorlevel% NEQ 0 (echo Something error happened and the above command returned exit code not equal to 0: %errorlevel%) else (Success^^! Exit code is %errorlevel%)` is just an example. – double-beep Mar 15 '19 at 16:22
1 Answers
1
Error codes are set to ERRORLEVEL so your batch file might look like this:
IF %ERRORLEVEL% == 0 (
do stuff
)

Zach Pedigo
- 396
- 2
- 9
-
You can check for any errorlevel but in your case it seems like you would want to be checking for if the errorlevel is greater than 0 which would indicate that something has happened in in your docker stuff. – Zach Pedigo Mar 15 '19 at 19:16