如何创建Docker覆盖网络?

时间:2019-05-01 16:05:38

标签: docker docker-swarm

我创建覆盖网络的努力是徒劳的。

docker network create --driver overlay new_network
Error response from daemon: This node is not a swarm manager. Use "docker swarm init" or "docker swarm join" to connect this node to swarm and try again.

Docker机器列表

 docker-machine ls
NAME              ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER     ERRORS
dev               -        virtualbox   Stopped                                       Unknown    
swarm-manager-1   -        virtualbox   Running   tcp://192.168.99.103:2376           v18.09.5   

如果我尝试

docker $(docker-machine config swarm-manager-1) swarm init --advertise-addr $(docker-machine ip swarm-manager-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.

如何创建覆盖网络? 如何检查群?

我正在使用Ubuntu 18.04。

编辑 可行

docker $(docker-machine config swarm-manager-1) network create --driver overlay new_network
ym9wva4e8ejqji9cn61tf14kv

任何地方的覆盖网络都不可见

docker network ls
NETWORK ID          NAME                                      DRIVER              SCOPE
ab450fe43ca5        bridge                                    bridge              local
14dbdf7dc1d9        chapter11_kong-net                        bridge              local
0a76583939bc        dockerapp_default                         bridge              local
b2c31f5e97c7        host                                      host                local
569e2a86568b        microservices-docker-go-mongodb_default   bridge              local
68174733413c        miki_default                              bridge              local
fbafcb186ac9        none 

为什么?

1 个答案:

答案 0 :(得分:1)

很可能您的计算机上具有不同的配置。您必须在示例中与docker network命令相同的上下文中运行docker swarm命令:

docker $(docker-machine config swarm-manager-1) network create --driver overlay new_network