Delay in catching docker exit code in bash script
Inside the container is a py script that craps out with a sys.exit(1) in about half runs.
Unless I set a "sleep" in the bash script windmill considers the run successful regardless of how the docker container exits. Anyone know why that is?
containerid=$(docker run -d crashing-container:v1.0 python main.py -r)
#sleep 1
exitcode=$(docker inspect --format='{{.State.ExitCode}}' $containerid)
echo "Container exit code: " $exitcode
if [ $exitcode -eq 0 ]; then
echo "Container {$containerid} ExitCode:{$exitcode} - Yay!"
exit 0 #unless sleep, bash script always exits through here...
else
echo "Container {$containerid} ExitCode:{$exitcode} - Fail!"
exit 1
fi