Some useful
List stacks or apps
Run the specified Compose file
List running services associated with an app
List tasks associated with an app
Inspect task or container
List container IDs
Tear down an application
Take down a single node swarm from the manager
#docker #cheatsheet #inspect #stack #swarm #service
docker
commands:docker stack ls
List stacks or apps
docker stack deploy -c <composefile> <appname>
Run the specified Compose file
docker service ls
List running services associated with an app
docker service ps <service>
List tasks associated with an app
docker inspect <task or container>
Inspect task or container
docker container ls -q
List container IDs
docker stack rm <appname>
Tear down an application
docker swarm leave --force
Take down a single node swarm from the manager
#docker #cheatsheet #inspect #stack #swarm #service
Removing docker network in swarm mode gives error below:
In order to remove the network you need to remove dangling containers that are bound to the network, to see those containers:
In
#docker #network #disconnect #swarm
Error response from daemon: network demo_net has active endpoints
In order to remove the network you need to remove dangling containers that are bound to the network, to see those containers:
docker network inspect demo_net
In
Containers
section you would see name of those containers. Grab the name of the container and use disconnect
as below to remove it from the network:docker network disconnect -f demo_net NAME_OF_YOUR_CONTAINER
#docker #network #disconnect #swarm
If your in docker swarm and you want to see log data of a specific service you can use
It sometimes has unexpected behaviours and does not print logs. Rather than
#docker #swarm #since #tail #log
--since
as below:docker service logs project_redis --since "1m" -f
It sometimes has unexpected behaviours and does not print logs. Rather than
--since
you can use tail
it is better in case you want to see recent logs:docker service logs project_redis --tail 1
#docker #swarm #since #tail #log
Kill zombie tasks in
1-
2- At the host the container running in, look up the
3-
It sweeps entries of the zombie tasks from swarm. Happy deploying! :)
#docker #swarm #zombie #no_trunk #shim
docker swarm
using steps below:1-
docker ps --no-trunc
to find the zombie container id.2- At the host the container running in, look up the
PID
of a docker-containerd-shim process by ps aux | grep <container id>
3-
kill <PID>
It sweeps entries of the zombie tasks from swarm. Happy deploying! :)
#docker #swarm #zombie #no_trunk #shim
In
Read more here:
- https://docs.docker.com/engine/swarm/manage-nodes/#update-a-node
The great thing about this labeling is in docker compose file that you can tell docker which server should get deployed on which server (node):
#docker #node #swarm #label #role
docker
swarm mode you can list nodes with docker node ls
. If you want to assign a label to each node you can use the below command to update node labels. For example you can assign a key=value
pair like role=storage
to one of your node listed with the first command:docker node update --label-add role=storage YOUR_HOSTNAME
Read more here:
- https://docs.docker.com/engine/swarm/manage-nodes/#update-a-node
The great thing about this labeling is in docker compose file that you can tell docker which server should get deployed on which server (node):
deploy:
replicas: 4
placement:
constraints:
- node.labels.role == storage
NOTE:
role
is something that we ourselves have been defined. You can define your own as requirements vary.#docker #node #swarm #label #role
Docker Documentation
Manage nodes in a swarm
Manage existing nodes in a swarm