Reputation: 395
Use RestAPI to create a container with command "/bin/bash". The container is created successfully because the RestAPI returns container ID. But I can't start this container. Command "docker ps" always show no container, even after I manually start this container.
[root@CentOS Base]# curl -X POST -H "Content-Type: application/json" 127.0.0.1:4243/containers/create -d '{"Id" : "99", "Command" : "/bin/bash", "Image" : "centos", "Status" : "exit 0"}' {"Id":"c0384a81ba1e6bbb23c4268c580899f9e38afb9dec11e2107baafcf7744bf999","Warnings":null}
[root@CentOS Base]# docker start c0384a81ba1e6bbb23c4268c580899f9e38afb9dec11e2107baafcf7744bf999 c0384a81ba1e6bbb23c4268c580899f9e38afb9dec11e2107baafcf7744bf999
[root@CentOS Base]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@CentOS Base]#
Upvotes: 1
Views: 241
Reputation: 8905
docker ps -a
probably does show the container. It is stopped. It's important to note that containers are designed to stop once the command executed within them has exited. So when starting the container /bin/bash is executed and after that the container stops. You need to run the container with a command that stays active. Try running with "Command" : "ping -c 1000 localhost"
Upvotes: 1