Reputation: 61
I am using docker-machine with Google Compute Engine(GCE)
to run a
docker swarm cluster. I created a swarm successfully with 2
nodes
(swnd-01 & swnd-02) in the cluster. I created a daemon container
like this
in the swarm-manager environment:
docker run -d ubuntu /bin/bash
docker ps
shows the container running on swnd-01. When I tried
executing a command over the container using docker exec
I get the
error that container is not running while docker ps
shows otherwise.
I ssh
'ed into swnd-01 via docker-machine to come to know that container
exited as soon as it was created. I tried docker run
command inside the
swnd-01 but it still exits. I don't understand the behavior.
Any suggestions will be thankfully received.
Upvotes: 2
Views: 148
Reputation: 46548
The reason it exits is that the /bin/bash
command completes and a Docker container only runs as long as its main process (if you run such a container with the -it
flags the process will keep running while the terminal is attached).
As to why the swarm manager thought the container was still running, I'm not sure. I guess there is a short delay while Swarm updates the status of everything.
Upvotes: 1