1

After deploying a Python Docker container and successfully executing a script the container crashes and restarts in a loop after showing the following error message:

2017-06-19 13:22:49 [APP/PROC/WEB/0] OUT Exit status 0
2017-06-19 13:22:49 [CELL/0] OUT Exit status 0
2017-06-19 13:22:49 [CELL/0] OUT Destroying container
2017-06-19 13:22:49 [API/0] OUT Process has crashed with type: "web"
2017-06-19 13:22:49 [API/0] OUT App instance exited with guid 85e7922e-5a0c-4430-994a-324e5abc0c14 payload: {"instance"=>"", "index"=>0, "reason"=>"CRASHED", "exit_description"=>"2 error(s) occurred:\n\n* Codependent step exited\n* cancelled", "crash_count"=>1, "crash_timestamp"=>1497871369566402154, "version"=>"b9800e3a-b057-4cc5-b7e4-c01f9b3c6594"}

Executing the same docker image locally it does not throw any errors. The Python script I execute is doing a simple print command and I even implemented a handler for the SIGTERM signal that is sent into the container after execution.

jz22
  • 2,328
  • 5
  • 31
  • 50
  • Looks like a normal termination: `Exit status 0` not like a crash. It seems something tries to restart the container. – Henry Jun 19 '17 at 11:41
  • Running the same application on a local Docker executes the script properly and destroys the container. However on CloudFoundry it restarts the container in a loop. – jz22 Jun 19 '17 at 11:50
  • I have no experience with CloudFoundry. Did you specifiy somewhere the restart behaviour of the container. – Henry Jun 19 '17 at 12:06

1 Answers1

3

In CF, applications are not supposed to finish. But if your script only just prints something, it'll perform an exit 0 afterwards. Thus the app container is stopped and CF registers a "crash", and will then restart the application in accordance with the app lifecycle: https://docs.cloudfoundry.org/devguide/deploy-apps/app-lifecycle.html

Sandro Mathys
  • 474
  • 3
  • 7
  • Thank you for the enlightment. Is there a solution to fix the reboot? I do not mind the crash but I do not want the container to restart all the time. – jz22 Jun 19 '17 at 12:14
  • 1
    @user3080315 I don't think so, as apps are supposed to be always running. You'd have to implement some kind of workaround, like stopping the app from outside once it has crashed or adding an endless loop (with nothing but a long sleep in it) at the end of the script. – Sandro Mathys Jun 19 '17 at 12:45