Building docker container exits but build is successful

Every so often when we are building docker images I see that the job just stops building and then marks the job successful. It is supposed to push the image after building but this does not happen. It still executes the after script.

Any ideas on how to debug this issue?

Can you try increasing the memory of the machine which runs the container ? If the OS killed might have killed the process. I am also looking for solving such issues, where the job reports the truth.

We may need to write some script to Assert to make sure job is green or red.