Rest API成功创建后,Container不存在

时间:2015-09-16 21:59:35

标签: docker

使用RestAPI创建一个带有“/ bin / bash”命令的容器。容器已成功创建,因为RestAPI返回容器ID。 但我无法启动这个容器。即使我手动启动此容器,命令“docker ps”也始终不显示容器。

  

[root @ CentOS Base] #curl -X POST -H“Content-Type:application / json”127.0.0.1:4243/containers/create -d'{“Id”:“99”,“Command”: “/ bin / bash”,“图片”:“centos”,“状态”:“退出0”}'   { “ID”: “c0384a81ba1e6bbb23c4268c580899f9e38afb9dec11e2107baafcf7744bf999”, “警告”:空}

     

[root @ CentOS Base] #docker start c0384a81ba1e6bbb23c4268c580899f9e38afb9dec11e2107baafcf7744bf999   c0384a81ba1e6bbb23c4268c580899f9e38afb9dec11e2107baafcf7744bf999

     

[root @ CentOS Base] #docker ps   集装箱ID图像命令创建状态端口名称

     

[root @ CentOS Base]#

1 个答案:

答案 0 :(得分:1)

docker ps -a可能确实显示了容器。它被停止了。重要的是要注意容器被设计为一旦在其中执行的命令退出就停止。因此,当启动容器/ bin / bash时,容器停止。您需要使用保持活动的命令运行容器。尝试使用“Command”运行:“ping -c 1000 localhost”