为了深入了解Docker,我创建了一个执行python脚本的dockerfile。它工作正常,但脚本执行后容器崩溃。如何修改我的dockerfile以便在执行后销毁容器,而不是让容器崩溃并始终重新启动?执行代码后停止Docker容器
Dockerfile:
FROM python:3
ADD aa.py/
CMD [ "python", "./aa.py" ]
的Python:
print('Hello!')
错误消息:
2017-06-14 11:37:09 [CELL/0] OUT Starting health monitoring of container
2017-06-14 11:37:09 [APP/PROC/WEB/0] OUT Hello!
2017-06-14 11:37:09 [APP/PROC/WEB/0] OUT Exit status 0
2017-06-14 11:37:09 [CELL/0] OUT Exit status 143
2017-06-14 11:37:09 [CELL/0] OUT Destroying container
2017-06-14 11:37:09 [API/0] OUT Process has crashed with type: "web"
2017-06-14 11:37:09 [API/0] OUT App instance exited with guid 6fdede46-6751-4725-ad78-b76262dbe701 payload: {"instance"=>"", "index"=>0, "reason"=>"CRASHED", "exit_description"=>"2 error(s) occurred:\n\n* 2 error(s) occurred:\n\n* Codependent step exited\n* cancelled\n* cancelled", "crash_count"=>4, "crash_timestamp"=>1497433029411246770, "version"=>"98e2a035-e38f-4169-95fb-2701c8486e9c"}
2017-06-14 11:37:09 [CELL/0] OUT Successfully destroyed container
2017-06-14 11:38:31 [CELL/0] OUT Creating container
你是怎么开始你的容器的?您可以使用'docker run --rm mypython'来执行脚本后移除你的容器。 – lvthillo
我在CloudFoundry上使用Docker。通过用户界面,我在Docker集线器仓库中输入并启动它。 – user3080315
我从来没有使用cloudfundry,所以不能帮助你。我会怀疑它试图重新启动,因为在cf中,因为只有在Docker中,此容器才会运行,显示消息并停止。 '--rm'选项将在运行后删除容器。我无法帮助你在比较中重现这一点。 – lvthillo