Reputation: 433
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?
Upvotes: 1
Views: 2841
Reputation: 12380
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
Upvotes: 1