My docker swarm build is as follows;
10.10.10.101 - Manager 1 - Ubuntu 22.04
10.10.10.102 - Manager 2 - Ubuntu 22.04
10.10.10.111 - Worker 1 - Ubuntu 22.04
10.10.10.112 - Worker2 - Ubuntu 22.04
10.10.10.131 - Nfs server - Ubuntu 22.04
Deploy mode for my two Postgres and Portainer servers
pull to replicated and worker parameters “docker stack deploy -c docker-compose.yml traefik”
But I cannot access these two servers in any way.
When I change the deploy mode to global and manager; I can access my servers.
I get tcp dial error error in traffic logs.
When I look at the portainer interface ;
a-) I see my manager and worker servers.
b-) For example, when I set customer1 as global and manager and set customer2 as replicated and worker
in portainer;
I encounter these screenshots.
Although I spent a very long time, unfortunately I could not solve the problem. Thank you very, very much in advance to friends who can help.
version: ‘3.9’
services:
traefik:
image: ‘traefik:v3.1’
hostname: ‘{{.Node.Hostname}}’
ports:
- “80:80”
- “443:443”
- “5432:5432”
deploy:
mode: global
placement:
constraints:
- node.role==manager
volumes:
- “/var/run/docker.sock:/var/run/docker.sock:ro”
- “traefik-certificates:/certificates”
command:
- “–api.dashboard=true”
- “–log.level=INFO”
- “–accesslog=true”
- “–providers.docker.network=proxy”
- “–providers.docker.exposedbydefault=false”
- “–providers.swarm.endpoint=unix:///var/run/docker.sock”
- “–entrypoints.http.address=:80”
- “–entrypoints.https.address=:443”
- “–entrypoints.postgres.address=:5432”
- “--certificatesresolvers.stagingresolver.acme.email=berk.xxxxx@gmail.com”
- “–certificatesresolvers.stagingresolver.acme.tlschallenge=true”
- “–certificatesresolvers.stagingresolver.acme.storage=/certificates/acme.json”
- “–certificatesresolvers.stagingresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory”
networks:
- proxy
labels:
- “traefik.enable=true”
- “traefik.docker.network=proxy”
- “traefik.http.middlewares.https-redirect.redirectscheme.scheme=https”
- “traefik.http.middlewares.https-redirect.redirectscheme.permanent=true”
- “traefik.http.routers.traefik-public-http.rule=Host(traefik.example.com)”
- “traefik.http.routers.traefik-public-http.entrypoints=http”
- “traefik.http.routers.traefik-public-http.middlewares=https-redirect”
- “traefik.http.routers.traefik-public-https.rule=Host(traefik.example.com)”
- “traefik.http.routers.traefik-public-https.entrypoints=https”
- “traefik.http.routers.traefik-public-https.tls=true”
- “traefik.http.routers.traefik-public-https.service=api@internal”
- “traefik.http.routers.traefik-public-https.tls.certresolver=stagingresolver”
- “traefik.http.services.traefik-public.loadbalancer.server.port=80”
portainer:
image: portainer/portainer-ce:latest
command: -H unix:///var/run/docker.sock
volumes:
- “/var/run/docker.sock:/var/run/docker.sock”
- “portainer_data:/data”
networks:
- proxy
deploy:
mode: global
placement:
constraints:
- node.role==manager
labels:
- “traefik.enable=true”
- “traefik.http.routers.portainer.rule=Host(portainer.example.com)”
- “traefik.http.routers.portainer.entrypoints=http”
- “traefik.http.middlewares.portainer-https-redirect.redirectscheme.scheme=https”
- “traefik.http.routers.portainer.middlewares=portainer-https-redirect”
- “traefik.http.routers.portainer-secured.rule=Host(portainer.example.com)”
- “traefik.http.routers.portainer-secured.entrypoints=https”
- “traefik.http.routers.portainer-secured.tls=true”
- “traefik.http.routers.portainer-secured.tls.certresolver=stagingresolver”
- “traefik.http.services.portainer.loadbalancer.server.port=9000”
customer_000001_postgres:
image: postgres:latest
environment:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres001
volumes:
- customer_000001:/var/lib/postgresql/data
networks:
- proxy
deploy:
mode: global
placement:
constraints:
- node.role==manager
labels:
- “traefik.enable=true”
- “traefik.tcp.routers.customer_000001_postgres.entrypoints=postgres”
- “traefik.tcp.routers.customer_000001_postgres.rule=HostSNI(customer1.example.com)”
- “traefik.tcp.routers.customer_000001_postgres.tls=true”
- “traefik.tcp.routers.customer_000001_postgres.tls.certresolver=stagingresolver”
- “traefik.tcp.services.customer_000001_postgres.loadbalancer.server.port=5432”
customer_000002_postgres:
image: postgres:latest
environment:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres002
volumes:
- customer_000002:/var/lib/postgresql/data
networks:
- proxy
deploy:
mode: replicated
replicas: 1
placement:
constraints:
- node.role==worker
labels:
- “traefik.enable=true”
- “traefik.tcp.routers.customer_000002_postgres.entrypoints=postgres”
- “traefik.tcp.routers.customer_000002_postgres.rule=HostSNI(customer2.example.com)”
- “traefik.tcp.routers.customer_000002_postgres.tls=true”
- “traefik.tcp.routers.customer_000002_postgres.tls.certresolver=stagingresolver”
- “traefik.tcp.services.customer_000002_postgres.loadbalancer.server.port=5432”
volumes:
traefik-certificates:
driver: local
driver_opts:
type: nfs
o: addr=10.10.10.131,nfsvers=4
device: “:/mnt/nfsdisk/certificates”
portainer_data:
driver: local
customer_000001:
driver: local
driver_opts:
type: nfs
o: addr=10.10.10.131,nfsvers=4
device: “:/mnt/nfsdisk/customer_000001/postgres_data”
customer_000002:
driver: local
driver_opts:
type: nfs
o: addr=10.10.10.131,nfsvers=4
device: “:/mnt/nfsdisk/customer_000002/postgres_data”
networks:
proxy:
name: proxy
driver: overlay
attachable: true
driver_opts:
com.docker.network.driver.mtu: 1400

