0

I am trying to create a docker container in a swarm. I am expecting to see the service when I execute "docker service ls", and to see a container running when I execute "docker ps". I see the service but not the container.

[root@docker01-staging dcater]# docker service create --name dbcservice alpine ping 127.0.0.1
lm2b7g3kbnbn11m33y15bplqf
overall progress: 1 out of 1 tasks
1/1: running   [==================================================>]
verify: Service converged


[root@docker01-staging dcater]# docker service ls
ID                  NAME                             MODE                REPLICAS            IMAGE                                                                                       PORTS
maad961bcum4        dbcservice                       replicated          1/1                 alpine:latest

[root@docker01-staging dcater]# docker ps --filter name=dbcservice
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Any idea what I am missing?

2 Answers 2

0

I figured out the answer (roughly). I'm not sure I have the terminology right, but docker01-staging is the management node. I checked docker02-staging, and that's actually where the process is running:

[root@docker02-staging dcater]# docker ps --filter name=dbcservice
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
3f30b6fa3d40        alpine:latest       "ping 127.0.0.1"    56 minutes ago      Up 56 minutes                           dbcservice.1.fke9ljd8brpwzhklzqy0agt1r
1
  • You can use docker service ps dbcservice on your management node
    – ppbb
    Feb 12, 2020 at 1:31
0

docker ps is a docker level command that talks to the docker daemon running on the same node that docker ps is run, whereas in the context of Docker Swarm, docker service is a swarm level command, querying the swarm state. Thus docker ps must always be executed on each node in the swarm to see the running containers.

There is also docker node ps which is a swarm level command that will show the containers running on swarm nodes using the swarm node name. Use docker node ls to show the swarm node names.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.