实验环境是两台Linux服务器, 互相可以ping通
docker swarm init --advertise-addr=192.168.10.228
docker swarm join --token SWMTKN-1-1o9b0gvb2x39f8wl9dhv35ovt3zll5i09w92vyc96f4i9xn8wc-48u9v08chs136z1c436tih5m1 192.168.10.228:2377 (ps: 这是在另一台服务器上执行)
docker network create -d overlay wordpress
docker service create --name=mysql --env MYSQL_ROOT_PASSWORD=dev123 --env MYSQL_DATABASE=wordpress --network wordpress --mount type=volume,source=mysql-data,destination=/var/lib/mysql mysql:5.7
docker service create --name wordpress -p 80:80 --env WORDPRESS_DB_PASSWORD=dev123 --env WORDPRESS_DB_HOST=mysql --network wordpress wordpress
报错: MySQL Connection Error: (2002) php_network_getaddresses: getaddrinfo failed: Name or service not known