在环境上通过 docker 查看节点列表时,报错如下:

Error response from daemon: This node is not a swarm manager._2d

  解决方法:

Error response from daemon: This node is not a swarm manager._docker_02

 具体code如下:

root@controller1:~# docker swarm init --advertise-addr 127.0.0.1
Error response from daemon: This node is already part of a swarm. Use "docker swarm leave" to leave this swarm and join another one.
root@controller1:~#
root@controller1:~#
root@controller1:~#
root@controller1:~#
root@controller1:~# docker swarm leave
Node left the swarm.
root@controller1:~#
root@controller1:~#
root@controller1:~# docker swarm init --advertise-addr 127.0.0.1
Swarm initialized: current node (thdeb7dj2db5g2dqca0wi23nx) is now a manager.

To add a worker to this swarm, run the following command:

    docker swarm join --token SWMTKN-1-3c97io1b67vlrhjl0oz8ry18omwxbwmptwnp27h4nfdscwa8hu-6efe0zj8qnh3i8og4ehgv6997 127.0.0.1:2377

To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.

root@controller1:~# docker swarm join-token -q manager
SWMTKN-1-3c97io1b67vlrhjl0oz8ry18omwxbwmptwnp27h4nfdscwa8hu-ajbf1zaamq09n1i2lbhlemcld
root@controller1:~#
root@controller1:~#
root@controller1:~# docker node ls
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION
thdeb7dj2db5g2dqca0wi23nx *   controller1         Ready               Active              Leader              19.03.9
root@controller1:~#
root@controller1:~#