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

AKAI TSUKI

System development or Technical something

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

docker service create

[root@docker01 ~]# docker service create --endpoint-mode dnsrr --name demo --replicas 1 nginx
[root@docker01 ~]# docker service scale demo=3

[root@docker01 ~]# docker service create --endpoint-mode dnsrr --name client --replicas 1 centos tail -f /dev/null
[root@docker01 ~]# docker service scale client=4

node, service STATUS

[root@docker01 ~]# docker service ls
ID            NAME    REPLICAS  IMAGE   COMMAND
0e0cy7i02kqu  demo    3/3       nginx
d5i158svoj3b  client  4/4       centos  tail -f /dev/null
[root@docker01 ~]# docker service ps demo
ID                         NAME    IMAGE  NODE      DESIRED STATE  CURRENT STATE           ERROR
8xzfg83melswmf79hk8l6tdyf  demo.1  nginx  docker01  Running        Running 35 minutes ago
a2xajycx67mbm04ukqo1kdw35  demo.2  nginx  docker01  Running        Running 31 minutes ago
0ya0tce3kmq7n4qsk7xcyzgdv  demo.3  nginx  docker02  Running        Running 31 minutes ago
[root@docker01 ~]# docker service ps client
ID                         NAME      IMAGE   NODE      DESIRED STATE  CURRENT STATE           ERROR
borscs0lgt5a8bn8aldp0i9cq  client.1  centos  docker02  Running        Running 10 minutes ago
ez0wnk2o0ct3b02hmi74tppsh  client.2  centos  docker01  Running        Running 9 minutes ago
1qwupnelu9nvk39a1lf1wj20v  client.3  centos  docker01  Running        Running 9 minutes ago
3eqdl7xzsxp4s4ae01k1ggf8h  client.4  centos  docker02  Running        Running 9 minutes ago
[root@docker01 ~]#

container(docker01)

[root@docker01 ~]# docker ps
CONTAINER ID        IMAGE                     COMMAND                  CREATED             STATUS              PORTS               NAMES
7478ff0dbefd        centos:latest             "tail -f /dev/null"      12 minutes ago      Up 12 minutes                           client.3.1qwupnelu9nvk39a1lf1wj20v
bb64f5bf45aa        centos:latest             "tail -f /dev/null"      12 minutes ago      Up 12 minutes                           client.2.ez0wnk2o0ct3b02hmi74tppsh
7be83b69bd1d        nginx:latest              "nginx -g 'daemon off"   34 minutes ago      Up 34 minutes       80/tcp, 443/tcp     demo.2.a2xajycx67mbm04ukqo1kdw35
196df6ad1baf        nginx:latest              "nginx -g 'daemon off"   38 minutes ago      Up 38 minutes       80/tcp, 443/tcp     demo.1.8xzfg83melswmf79hk8l6tdyf
[root@docker01 ~]#

[root@docker01 ~]# docker inspect -f '{{range .NetworkSettings.Networks }}{{.IPAddress}}{{end}}' client.3.1qwupnelu9nvk39a1lf1wj20v
172.17.0.5
[root@docker01 ~]# docker inspect -f '{{range .NetworkSettings.Networks }}{{.IPAddress}}{{end}}' client.2.ez0wnk2o0ct3b02hmi74tppsh
172.17.0.4
[root@docker01 ~]# docker inspect -f '{{range .NetworkSettings.Networks }}{{.IPAddress}}{{end}}' demo.2.a2xajycx67mbm04ukqo1kdw35
172.17.0.3
[root@docker01 ~]# docker inspect -f '{{range .NetworkSettings.Networks }}{{.IPAddress}}{{end}}' demo.1.8xzfg83melswmf79hk8l6tdyf
172.17.0.2
[root@docker01 ~]#

container(docker02)

[root@docker02 ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
6e9bdef50320        centos:latest       "tail -f /dev/null"      13 minutes ago      Up 13 minutes                           client.4.3eqdl7xzsxp4s4ae01k1ggf8h
f2fc09ca4922        centos:latest       "tail -f /dev/null"      13 minutes ago      Up 13 minutes                           client.1.borscs0lgt5a8bn8aldp0i9cq
103a7924f96d        nginx:latest        "nginx -g 'daemon off"   35 minutes ago      Up 35 minutes       80/tcp, 443/tcp     demo.3.0ya0tce3kmq7n4qsk7xcyzgdv
[root@docker02 ~]#

[root@docker02 ~]# docker inspect -f '{{range .NetworkSettings.Networks }}{{.IPAddress}}{{end}}' client.4.3eqdl7xzsxp4s4ae01k1ggf8h
172.17.0.4
[root@docker02 ~]# docker inspect -f '{{range .NetworkSettings.Networks }}{{.IPAddress}}{{end}}' client.1.borscs0lgt5a8bn8aldp0i9cq
172.17.0.3
[root@docker02 ~]# docker inspect -f '{{range .NetworkSettings.Networks }}{{.IPAddress}}{{end}}' demo.3.0ya0tce3kmq7n4qsk7xcyzgdv
172.17.0.2
[root@docker02 ~]#