为了更深入地了解Docker,我创建了一个Dockerfile来执行Python脚本。虽然它可以正常运行,但是在脚本执行完后容器会崩溃。那么我该如何修改我的Dockerfile,以便在脚本执行完成后销毁容器,而不是让容器一直崩溃和重新启动?
Dockerfile内容:
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--rm
选项将在运行后删除容器。我无法帮助您在CloudFoundry中重现此问题。 - lvthillo