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

1
  • What networks does it leave? Jan 19, 2018 at 17:33

2 Answers 2

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)
2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.