Cannot leave swarm mode

2019-07-20 16:40发布

问题:

I've been tinkering with new Docker swarm mode. I can't fully recall the steps that I did, but now I'm stuck in situation where my docker engine is as a worker in a non-existing swarm:

$ docker info
...
Swarm: active
 NodeID: 1vndsuqa0r3paswufs7eq4po3
 Is Manager: false
 Node Address: 192.168.65.2
...

$ docker swarm leave
Error response from daemon: context deadline exceeded

$ docker version
Client:
 Version:      1.12.0
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   8eab29e
 Built:        Thu Jul 28 21:04:48 2016
 OS/Arch:      darwin/amd64
 Experimental: true

Server:
 Version:      1.12.0
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   8eab29e
 Built:        Thu Jul 28 21:04:48 2016
 OS/Arch:      linux/amd64
 Experimental: true

How could I get out the swarm mode?

回答1:

I believe this was a bug in 1.12.0 that has been resolved since (I believe the patch should be included in 1.12.3). Here is the Related Issue.

But if the problem persists with the new version somehow, there are a few additional options:

# Force quit the cluster

docker swarm leave --force

or

# Force a new cluster and leave properly

docker swarm init --force-new-cluster
docker swarm leave


回答2:

I finally managed to fix this by resetting docker back to factory defaults from Docker menu > Preferences > Uninstall / Reset > Reset to factory defaults (I'm using Docker for Mac beta). Note that this operation also swipes all docker images, volumes, networks, etc.