filmov
tv
Get container name from a docker swarm stack
Показать описание
In this demo, I will get a container name to inspect or check the logs
1- Get Services of a specific stack
docker stack services mongo-express
2- Get the running tasks of this service
docker service ps mongo-express_mongo-express --filter 'desired-state=Running' --no-trunc --format 'table{{.ID}}\t{{.Name}}\t{{.Node}}'
3- Log in to the node where the task is running
4- Get the container name
the container name will be named in this format:
CONTAINER NAME = TASK NAME + '.' + TASK ID
5- Verify container name
docker ps -a --format 'table{{.ID}}\t{{.Names}}'
1- Get Services of a specific stack
docker stack services mongo-express
2- Get the running tasks of this service
docker service ps mongo-express_mongo-express --filter 'desired-state=Running' --no-trunc --format 'table{{.ID}}\t{{.Name}}\t{{.Node}}'
3- Log in to the node where the task is running
4- Get the container name
the container name will be named in this format:
CONTAINER NAME = TASK NAME + '.' + TASK ID
5- Verify container name
docker ps -a --format 'table{{.ID}}\t{{.Names}}'