1

I cannot connect to a service running on docker swarm. The swarm seems ok because I can connect to other containers running on it. I running the service with docker stack deploy -c docker-compose.yaml nifi and the docker compose file is:

version: "3.3"
services:
  registry:
    image: apache/nifi-registry:0.3.0
    ports:
      - "18080:18080"
  deploy:
    replicas: 1
    restart_policy:
      condition: on-failure

When I run this without the swarm i.e. docker-compose -f docker-compose.yaml up it works fine and I can browse to it. When I run it with docker stack deploy -c docker-compose.yaml nifi I see the same log entries for the service but cannot browse to it.

$ docker version

Client:
  Version:      18.03.1-ce
  API version:  1.37
  Go version:   go1.9.5
  Git commit:   9ee9f40
  Built:        Wed Jun 20 21:43:51 2018
  OS/Arch:      linux/amd64
  Experimental: false
  Orchestrator: swarm

Server:
  Engine:
    Version:      18.03.1-ce
    API version:  1.37 (minimum version 1.12)
    Go version:   go1.9.5
    Git commit:   9ee9f40
    Built:        Wed Jun 20 21:42:00 2018
    OS/Arch:      linux/amd64
    Experimental: false

Does anyone have suggestions for fixing or troubleshooting this?

BenCaldwell
  • 323
  • 1
  • 15
  • What do you mean 'browse' do it? What ip are you hitting? In the compose example this will likely be localhost, in the swarm example it will be the init address that you created the swarm with (assuming you're running a single manager node). – johnharris85 Jan 10 '19 at 04:29
  • @johnharris85 By browse to it I mean point a browser at one of the hosts in the swarm on port 18080. I have tried all hosts, normally any should work with swarm mesh networking. – BenCaldwell Jan 10 '19 at 06:26

1 Answers1

1

In swarm

ports:
  - "18080:18080"

will expose port on all swarm nodes and in case of use of the port on some of the nodes by another service you can have problems

you can expose port only on host with container

services:
  registry:
    ports:
      - target: 18080
        published: 18080
        mode: host
Ryabchenko Alexander
  • 10,057
  • 7
  • 56
  • 88