読者です 読者をやめる 読者になる 読者になる

AKAI TSUKI

System development or Technical something

service create option "--endpoint-mode dnsrr" with overlay network

docker network

[root@docker01 ~]# docker network create --driver overlay overlay1

docker service create

[root@docker01 ~]# docker service create --endpoint-mode dnsrr --name test --network overlay1 --replicas 1 nginx
[root@docker01 ~]# docker service create --endpoint-mode dnsrr --name client --network overlay1 --replicas 1 centos tail -f /dev/null

[root@docker01 ~]# docker service scale test=4
[root@docker01 ~]# docker service scale client=3

node, service status

[root@docker01 ~]# docker node ls
ID                           HOSTNAME  STATUS  AVAILABILITY  MANAGER STATUS
aldkiawrxwc5wti5z8nf6j1k7    docker02  Ready   Active
aqg2mnbz4tw6tu51h8h80w3ow *  docker01  Ready   Active        Leader
[root@docker01 ~]# docker service ls
ID            NAME    REPLICAS  IMAGE   COMMAND
1eaye43egvr0  test    4/4       nginx
3l3yjxdgf6jb  client  3/3       centos  tail -f /dev/null
[root@docker01 ~]#

docker01

[root@docker01 ~]# docker inspect -f '{{range .NetworkSettings.Networks}}{{ .IPAddress}}{{end}}' client.1.1n4qwio5tp06tx6g7p25wgn3v
10.0.0.4
[root@docker01 ~]# docker inspect -f '{{range .NetworkSettings.Networks}}{{ .IPAddress}}{{end}}' client.2.dtufzfhqyg46ztngqelgzl7go
10.0.0.8
[root@docker01 ~]# docker inspect -f '{{range .NetworkSettings.Networks}}{{ .IPAddress}}{{end}}' test.4.81xmfypsharpuoinldxdjufw5
10.0.0.7
[root@docker01 ~]#

docker02

[root@docker02 ~]# docker inspect -f '{{range .NetworkSettings.Networks}}{{ .IPAddress}}{{end}}' client.3.dowg24r4hqwjygtrf4hzu3qf7
10.0.0.9
[root@docker02 ~]# docker inspect -f '{{range .NetworkSettings.Networks}}{{ .IPAddress}}{{end}}' test.1.2hk1ijiw1xscgm6dayf59d3ik
10.0.0.2
[root@docker02 ~]# docker inspect -f '{{range .NetworkSettings.Networks}}{{ .IPAddress}}{{end}}' test.2.3hc8clkxwb9bxxcqi7qkal541
10.0.0.5
[root@docker02 ~]# docker inspect -f '{{range .NetworkSettings.Networks}}{{ .IPAddress}}{{end}}' test.3.eowc0co7m8remybcl3st61s3n
10.0.0.6
[root@docker02 ~]#