Hi,
my goal is to run multiple instances of a docker-compose file with different entrypoint ports. I only want to expose this one port which serves both my backend and frontend.
For this I created following docker-compose.yml:
version: '3.8'
services:
reverse-proxy:
# The official v2 Traefik docker image
image: traefik:v2.4
# Enables the web UI and tells Traefik to listen to docker
command:
# Traefik will listen on port 8080 by default for API request.
- '--api.insecure=true'
# Enabling docker provider
- '--providers.docker'
# Do not expose containers unless explicitly told so
- '--providers.docker.exposedbydefault=false'
- '--entryPoints.${PORT}-web.address=:${PORT}'
ports:
# The HTTP port
- ${PORT}:${PORT}
# The Web UI (enabled by --api.insecure=true)
# - '8082:8080'
volumes:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock
postgres:
image: postgres:13.2
environment:
- POSTGRES_USER=oip
- POSTGRES_PASSWORD=
- POSTGRES_HOST_AUTH_METHOD=trust
jhipster:
build: ./jhipster
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://postgres:5432/backend
# ports:
# - 8080:8080
depends_on:
- postgres
labels:
- 'traefik.enable=true'
- 'traefik.http.routers.port-${PORT}-jhipster.rule=PathPrefix(`/api`)'
- 'traefik.http.routers.port-${PORT}-jhipster.entrypoints=${PORT}-web'
frontend:
build: ./frontend
# ports:
# - 3000:3000
depends_on:
- jhipster
labels:
- 'traefik.enable=true'
- 'traefik.http.routers.port-${PORT}-frontend.rule=PathPrefix(`/`)'
- 'traefik.http.routers.port-${PORT}-frontend.entrypoints=${PORT}-web'
I run an instance like this:
PORT=50777 COMPOSE_PROJECT_NAME=PRO777 docker-compose up
To get multiple instances of this docker compose to run I had to parameterize some of the service names so they don't clash within traefik. Didn't find a better way to get this to start.
It sort of works but the instances show following errors: reverse-proxy_1 | time="2021-07-25T18:46:02Z" level=error msg="entryPoint \"50777-web\" doesn't exist" routerName=port-50777-jhipster@docker entryPointName=50777-web
And also in the dashboard always the services of other instances are shown as failed.
Is there a way to isolate the the traefik instances? Like one traefik per docker-compose which does not know anything about the other running ones?
Thanks in advance.