李明
|
server01
docker version
docker network ls
ifconfig
docker swarm init --advertise-addr 192.168.66.101
server02
server03
在server01中添加了server02 和server03的work后,查看网络
docker network ls
docker swarm的如何高可用
docker node ls
docker node promote docker-swarm-02 docker node promote docker-swarm-03
PS:以上就完成高可用的docker swarm的集群环境,其实真心比其他的简单。 测试集群环境
docker service create --name test1 alpine ping www.baidu.com docker service ls
docker service logs test1
docker service create --name nginx nginx docker service ls
docker service ls docker service update --publish-add 8080:80 nginx docker service ls
docker service scale nginx=3 docker service ls
自定义网络添加到docker swarm中。
docker service rm nginx test1
docker network create -d overlay idig8-overlay
docker service create --network idig8-overlay --name nginx -p 8080:80 nginx
docker service create --network idig8-overlay --name alpine alpine ping www.baidu.com
docker service ps alpine
docker ps docker exec -it 387dd735de74 sh ping nginx
PS:当前的网络Ingress,容器之间的访问方式可以通过名字访问。在自定义的网络下swarm每个service,都创建一个dnsadress,一定要是自定义的overlay的。
docker service create --name nginx-b --endpoint-mode dnsrr -p 8090:80 nginx
docker service updata --network-add idig8-overlay nginx-b
version: "3.4" services: alpine: image: alpine command: - "ping" - "www.baidu.com" networks: - "idig8-overlay" deploy: replicas: 2 restart_policy: condition: on-failure resources: limits: cpus: "0.1" memory: 50M depends_on: - nginx nginx: image: nginx networks: - "idig8-overlay" ports: - "8080:80" networks: idig8-overlay: external: true
docker stack ls # -c 文件名 组名 docker stack deploy -c service.yml test
PS:dockerSwarm的服务发现,负载均衡。
|
2019-02-14 10:49:26