8

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

user1867382
  • 414
  • 3
  • 13

2 Answers2

11

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)
Harald Albers
  • 1,913
  • 16
  • 20
2

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

Oliver Sahner
  • 170
  • 2
  • 5