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

AKAI TSUKI

System development or Technical something

service create option "--endpoint-mode vip"

--endpoint-mode vip を指定しています。
外部からnginxにアクセスするために80番ポートを指定します。

service create

[root@docker01 ~]# docker service create --endpoint-mode vip --name demo-vip --replicas 1 -p 80:80 nginx
bnbd8ngo3nf8yh6777gt7wg3c
[root@docker01 ~]# docker service ls
ID            NAME      REPLICAS  IMAGE  COMMAND
bnbd8ngo3nf8  demo-vip  4/4       nginx
[root@docker01 ~]#

Node(docker01)

[root@docker01 ~]# docker ps
CONTAINER ID        IMAGE                     COMMAND                  CREATED             STATUS              PORTS               NAMES
fdae78c84d68        nginx:latest              "nginx -g 'daemon off"   10 seconds ago      Up 6 seconds        80/tcp, 443/tcp     demo-vip.2.0iq40ti08fgikctn3p3n9hv51
c1d1cf20d956        nginx:latest              "nginx -g 'daemon off"   10 seconds ago      Up 7 seconds        80/tcp, 443/tcp     demo-vip.3.8vyah0pp7e6d59k77079a72vn
e316860eb322        weaveworks/scope:0.16.1   "/home/weave/entrypoi"   9 hours ago         Up 9 hours                              weavescope
[root@docker01 ~]#

[root@docker01 ~]# docker network inspect ingress
[
    {
        "Name": "ingress",
        "Id": "46865yuyi768xtrjuh9eivj5i",
        "Scope": "swarm",
        "Driver": "overlay",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "10.255.0.0/16",
                    "Gateway": "10.255.0.1"
                }
            ]
        },
        "Internal": false,
        "Containers": {
            "c1d1cf20d9561579abbc5b4f5c3351417578271e362357369ff2af4feb7cc82a": {
                "Name": "demo-vip.3.8vyah0pp7e6d59k77079a72vn",
                "EndpointID": "9f255cd39bcefef5729cf5a3f7e97523ffc691146dc1b494d0c435558a7ee5e0",
                "MacAddress": "02:42:0a:ff:00:08",
                "IPv4Address": "10.255.0.8/16",
                "IPv6Address": ""
            },
            "fdae78c84d680f75f32d48d2334cc22ed31649d93614860e8ba5ce89d21a074e": {
                "Name": "demo-vip.2.0iq40ti08fgikctn3p3n9hv51",
                "EndpointID": "94d025123ee666d06fd9fab9adc347150141ecc7a6987ec9633c0cf403b71391",
                "MacAddress": "02:42:0a:ff:00:07",
                "IPv4Address": "10.255.0.7/16",
                "IPv6Address": ""
            },
            "ingress-sbox": {
                "Name": "ingress-endpoint",
                "EndpointID": "f32b20caf7e4b2fae7bb85ccfde65807db8340d67446d46172ecff7be12ea739",
                "MacAddress": "02:42:0a:ff:00:03",
                "IPv4Address": "10.255.0.3/16",
                "IPv6Address": ""
            }
        },
        "Options": {
            "com.docker.network.driver.overlay.vxlanid_list": "256"
        },
        "Labels": {}
    }
]
[root@docker01 ~]#

Node(docker02)

[root@docker02 ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
94e805d204e7        nginx:latest        "nginx -g 'daemon off"   16 seconds ago      Up 14 seconds       80/tcp, 443/tcp     demo-vip.4.69wejbaast6tnddx7s5vwqyto
a8715e252eec        nginx:latest        "nginx -g 'daemon off"   33 seconds ago      Up 33 seconds       80/tcp, 443/tcp     demo-vip.1.a76mxysg10zfj79rpm327be46
[root@docker02 ~]#

[root@docker02 ~]# docker network inspect ingress
[
    {
        "Name": "ingress",
        "Id": "46865yuyi768xtrjuh9eivj5i",
        "Scope": "swarm",
        "Driver": "overlay",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "10.255.0.0/16",
                    "Gateway": "10.255.0.1"
                }
            ]
        },
        "Internal": false,
        "Containers": {
            "94e805d204e7aa10964f2700bcde3c139fb81f25135ed25054653bd34660093c": {
                "Name": "demo-vip.4.69wejbaast6tnddx7s5vwqyto",
                "EndpointID": "5e08ad01f09ba191be8413849cd57b015d9a7c651a5a05cbab90b1aee492a484",
                "MacAddress": "02:42:0a:ff:00:09",
                "IPv4Address": "10.255.0.9/16",
                "IPv6Address": ""
            },
            "a8715e252eec0b30ab83e82697c65266820d993fba6ab37590a9d5b6c6cf2030": {
                "Name": "demo-vip.1.a76mxysg10zfj79rpm327be46",
                "EndpointID": "2473f837bb66968f0380f5385051670a5e9b9caf20def5f2f72ab0ab61d02daf",
                "MacAddress": "02:42:0a:ff:00:06",
                "IPv4Address": "10.255.0.6/16",
                "IPv6Address": ""
            },
            "ingress-sbox": {
                "Name": "ingress-endpoint",
                "EndpointID": "27389e4101d99f17e60077ed91c917b43043a9a2ad45bf08c121b9a5ea22536d",
                "MacAddress": "02:42:0a:ff:00:04",
                "IPv4Address": "10.255.0.4/16",
                "IPv6Address": ""
            }
        },
        "Options": {
            "com.docker.network.driver.overlay.vxlanid_list": "256"
        },
        "Labels": {}
    }
]
[root@docker02 ~]#