Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is opposite of docker swarm init?

With a single host with a swarm that has been created with init, the host gets networks created etc.

There appears to be no 'docker swarm destroy' or similar that purges the system back to a state before the swarm. I did a leave --force but that left networks.

Do you have to manually tidy up a bunch of things you don't know were created or is there an easy command to get back to a clean setup?

Thanks

like image 407
user1867382 Avatar asked Jan 19 '18 16:01

user1867382


People also ask

What are the two types of docker swarm services?

Swarm mode has two types of services: replicated and global. For replicated services, you specify the number of replica tasks for the swarm manager to schedule onto available nodes.

What is the default mode for a swarm?

By default Docker Swarm uses a default address pool 10.0. 0.0/8 for global scope (overlay) networks. Every network that does not have a subnet specified will have a subnet sequentially allocated from this pool.

How do I get out of swarm mode?

Leave the swarmRun the docker swarm leave command on a node to remove it from the swarm. For example to leave the swarm on a worker node: $ docker swarm leave Node left the swarm. When a node leaves the swarm, the Docker Engine stops running in swarm mode.

What is docker swarm init?

docker swarm init generates two random tokens, a worker token and a manager token. When you join a new node to the swarm, the node joins as a worker or manager node based upon the token you pass to swarm join. After you create the swarm, you can display or rotate the token using swarm join-token.


2 Answers

docker swarm leave is the only command for reverting swarm membership. It cleans up all swarm specific artefacts that were created by docker stack deploy, e.g. overlay networks and secrets.

If you still got user defined networks after leaving the swarm, these were probably created by docker-compose. Note that this is not swarm specific, it can also happen in standalone mode.

You can get a listing of all networks that were created by docker-compose with

docker network ls --filter label=com.docker.compose.project

and get rid of them with

docker network rm $(docker network ls --filter label=com.docker.compose.project -q)
like image 162
Harald Albers Avatar answered Nov 11 '22 20:11

Harald Albers


If the docker instance was a manager: docker swarm leave --force.

like image 42
Oliver Sahner Avatar answered Nov 11 '22 22:11

Oliver Sahner