Docker Community Forums

Share and learn in the Docker community.

Can't access service in swarm

swarm

(Antonkallenberg) #1

Hi,

I’m new to Docker and stuck at moment, any help would be very appreciated.

I’m trying to setup a Swarm om my local computer (Windows 10, Hyper-v), everything seems to run fine within the containers but I can’t access the service from my host machine.

I’ve two machines in my swarm:

> docker-machine.exe ls
NAME           ACTIVE   DRIVER   STATE     URL                      SWARM   DOCKER    
docker-alpha   -        hyperv   Running   tcp://10.0.30.217:2376           v18.09.0
docker-omega   *        hyperv   Running   tcp://10.0.30.214:2376           v18.09.0

Running the container using docker run works great and I can access the container from my host:

> docker run -P -d nginxdemos/hello
6b51b47665e6e141243e851c4c8914d649987e653560bf92da3c1fb36d8cfff9

> docker container ls
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                   NAMES
6b51b47665e6        nginxdemos/hello    "nginx -g 'daemon of…"   5 seconds ago       Up 3 seconds        0.0.0.0:32772->80/tcp   agitated_minsky

> (wget http://10.0.30.214:32772).StatusCode
200

So I created a compose-file:

version: "3.2"
services:
  web:
    image: nginxdemos/hello:latest
    deploy:
      replicas: 2
      restart_policy:
        condition: on-failure
    ports:
      - "8080:80"
    networks:
      - webnet
networks:
   webnet:

…and deployed it to the swarm:

> docker stack deploy -c .\ngnix-compose.yml ngnix
Creating network ngnix_webnet
Creating service ngnix_web

> docker stack ls
NAME                SERVICES            ORCHESTRATOR
ngnix               1                   Swarm

> docker service ls
ID                  NAME                MODE                REPLICAS       PORTS
i0nk1g1ont19        ngnix_web           replicated          2/2           *:8080->80/tcp

> docker container ls
CONTAINER ID        IMAGE                     COMMAND                  PORTS 
d1ccb1b76a78        nginxdemos/hello:latest   "nginx -g 'daemon of…"    80/tcp         

> docker-machine ls
NAME           ACTIVE   DRIVER   STATE     URL                            DOCKER     
docker-alpha   -        hyperv   Running   tcp://10.0.30.217:2376         v18.09.0
docker-omega   *        hyperv   Running   tcp://10.0.30.214:2376         v18.09.0

But now I can’t access the deployed service… What am I missing?

> wget http://10.0.30.214:8080
wget : Unable to connect to the remote server

> wget http://10.0.30.217:8080
wget : Unable to connect to the remote server

Sorry if this is a stupid question…

Regards,
Anton


(Antonkallenberg) #2

Update!

This is due to a bug in Docker v18.09.0, see this issue: https://github.com/docker/machine/issues/4608.