How to get docker container id

I want to get the docker service container id. Is there any command for this?

I tried

docker service ps MyService

      

but this one only gives the ID of the service, I'm interested in the ID of the container in which the service is running.

+9


source to share


2 answers


try out

https://github.com/moby/moby/issues/31369

for f in $(docker service ps -q $service);do docker inspect --format '{{.NodeID}} {{.Status.ContainerStatus.ContainerID}}' $f; done



and

docker network inspect --verbose

from https://github.com/moby/moby/pull/31710

+11


source


try it:

docker ps -f name=YOUR_SERVICE_NAME --format "{{.ID}}"

      



SOURCE

0


source







All Articles