# 在主节点上 docker swarm init # 生成token .... docker swarm join --token SWMTKN-1-2g13vfvyap7rbuvvx966fe6i1sk3fp1xzd8y8qxj48ysk42uea-cbricttyqw5zhlycje1gtysmd 192.168.1.60:2377 #在其它节点添加到集群 docker swarm join --token SWMTKN-1-2g13vfvyap7rbuvvx966fe6i1sk3fp1xzd8y8qxj48ysk42uea-cbricttyqw5zhlycje1gtysmd 192.168.1.60:2377 # 在任意节点创建网络 docker network create -d overlay --attachable net
可能出现错误
Error response from daemon: could not choose an IP address to advertise since this system has multiple addresses on different interfaces (10.0.0.60 on eth0 and 192.168.1.60 on eth1) - specify one with --advertise-addr
这个错误出现在电脑有多个网卡时,原因是docker不知道该选用那个ip作为地址,解决方式很简单,就是在命令后面加上参数 --advertise-addr ip地址