karthick
karthick

Reputation: 175

docker stack network issue

i have crated the docker stack file as below, it created the 3 services, as excepted but i am unable to access out side of the host. and its not creating any port also. i have created a overlay network called test01. When i create a this manually via command line it works perfectly.

version: '3.0'
networks:
 default:
  external:
   name: test01
services:
 mssql:
  image: microsoft/mssql-server-windows-developer
  environment:
   - SA_PASSWORD=Password1
   - ACCEPT_EULA=Y
  ports:
   - 1433:1433
  volumes:
   - c:\Databases:c:\Databases
  deploy:
   placement:
    constraints: [node.labels.os==Windows]
 web:
  image: iiswithdb:latest
  ports:
   - 8080:8080
  deploy:
   replicas: 3
 lbs: 
  image: nginx:latest
  ports:
   - 80: 80
  deploy:
   placement:
    constraints: [node.labels.os==Windows]

Upvotes: 0

Views: 281

Answers (3)

mattsp1290
mattsp1290

Reputation: 66

Your services need to explicitly join the network you are defining. You can do this in the compose file. Otherwise they will use the default network created by the stack/compose. https://docs.docker.com/compose/compose-file/#networks

Upvotes: 1

karthick
karthick

Reputation: 175

C:\Users\Administrator>docker service ls
ID                  NAME                MODE                REPLICAS            IMAGE                                             PORTS
19qeljqt3wuf        test_mssql          replicated          1/1                 microsoft/mssql-server-windows-developer:latest   *:1433->1433/tcp
48gamfl4j4rl        test_web            replicated          3/3                 iiswithdb:latest                                  *:8080->8080/tcp
nxycxrigmz4u        test_lbs            replicated          1/1                 nginx:latest                                      *:80->80/tcp

C:\Users\Administrator>docker service ps test_lbs
ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE            ERROR               PORTS
81fm4xplekig        test_lbs.1          nginx:latest        node2               Running             Running 25 minutes ago

C:\Users\Administrator>docker service ps test_web
ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE               ERROR                              PORTS
aivzt7eagf4f        test_web.1          iiswithdb:latest    node1               Running             Running about an hour ago
sny1zf7osibq        test_web.2          iiswithdb:latest    node2               Running             Running about an hour ago
lwzlpaks1b4t         \_ test_web.2      iiswithdb:latest    node2               Shutdown            Failed about an hour ago    "task: non-zero exit (21479434…"
iav5mxqdbzoy        test_web.3          iiswithdb:latest    node3               Running             Running about an hour ago

C:\Users\Administrator>docker service ps test_mssql
ID                  NAME                IMAGE                                             NODE                DESIRED STATE       CURRENT STATE            ERROR               PORTS
pfu8qyw7vqxp        test_mssql.1        microsoft/mssql-server-windows-developer:latest   node2               Running             Running 26 minutes ago                    

Upvotes: 0

karthick
karthick

Reputation: 175

c:\Program Files\docker>docker network inspect test01
[
    {
        "Name": "test01",
        "Id": "8ffz8xihux13gx1uuhalub5by",
        "Created": "2017-09-11T12:30:35.7747711+05:30",
        "Scope": "swarm",
        "Driver": "overlay",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "10.0.0.0/24",
                    "Gateway": "10.0.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "2f283e7c21608d09a57a7cdef25a836d77c0ceb8030ae15796ff692e43b0eb73": {
                "Name": "test_web.1.jti1pyrgxv3v4yet9m9cpk0i4",
                "EndpointID": "bed2a5e0d077fcf48ab2d6fe419a8a69a45c3033e1a8602cf6395f93bec405b8",
                "MacAddress": "00:15:5d:f3:aa:1a",
                "IPv4Address": "10.0.0.5/24",
                "IPv6Address": ""
            },
            "8c55fad8ad54e5286bb7fc54da52ad1958854bceacbf0260400e7dc3c00c1c45": {
                "Name": "test_mssql.1.mn31bwoh8iwg5sge5rllh7gc9",
                "EndpointID": "00c6e68d6a22ee0dc5ad90cda7ab958323a0b07206ce4583f11baa8b3476de8f",
                "MacAddress": "00:15:5d:f3:aa:23",
                "IPv4Address": "10.0.0.3/24",
                "IPv6Address": ""
            }
        },
        "Options": {
            "com.docker.network.driver.overlay.vxlanid_list": "4097",
            "com.docker.network.windowsshim.hnsid": "b76fa7e3-530d-4133-b72a-1d1818cd3c16"
        },
        "Labels": {},
        "Peers": [
            {
                "Name": "node2-f3dedf0e26d9",
                "IP": "10.30.50.10"
            },
            {
                "Name": "node3-2e1ad7fb91be",
                "IP": "10.30.50.13"
            }
        ]
    }

]

Below is the output

c:\Program Files\docker>docker service ls
ID                  NAME                MODE                REPLICAS            IMAGE                                             PORTS
bo9uovidd4z3        test_web            replicated          3/3                 iiswithdb:latest                                  *:8080->8080/tcp
sujwg53gjnp3        test_lbs            replicated          0/1                 nginx:latest                                      *:80->80/tcp
vyxyoaji8jkd        test_mssql          replicated          1/1                 microsoft/mssql-server-windows-developer:latest   *:1433->1433/tcp

c:\Program Files\docker>docker service ps test_mssql
ID                  NAME                IMAGE                                             NODE                DESIRED STATE       CURRENT STATE           ERROR               PORTS
mn31bwoh8iwg        test_mssql.1        microsoft/mssql-server-windows-developer:latest   node2               Running             Running 6 minutes ago

When i inspect SQL server container i can't find any port taged

c:\Program Files\docker>docker service ps test_lbs
ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE            ERROR               PORTS
j4x806u1ucdr        test_lbs.1          nginx:latest                            Running             Pending 32 minutes ago

c:\Program Files\docker>docker service ps test_web
ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE            ERROR                              PORTS
jti1pyrgxv3v        test_web.1          iiswithdb:latest    node2               Running             Running 22 minutes ago
1gudznmi9ufz         \_ test_web.1      iiswithdb:latest    node2               Shutdown            Failed 27 minutes ago    "task: non-zero exit (21479434…"
xxkr98na4qsy        test_web.2          iiswithdb:latest    node3               Running             Running 29 minutes ago
7j1y6vc90qvf        test_web.3          iiswithdb:latest    node3               Running             Running 29 minutes ago

Upvotes: 0

Related Questions