As a disclaimer, my question may be similar to some already discussed on this forum, but I just haven't found the exact solution.
That being said, I've got a bunch of containers in Docker Compose that must run under Traefik. I want to expose some of them to be accessible by the great world from a browser. What I don't currently have (and don't have the possibility to get) is a public domain name. I want containers to be accessible by mere IPv4 + port, like: "http(s)://80.X.X.X:1234" or "http(s)://80.X.X.X:9000/some/path". Currently I can't make it happen.
So my Docker Compose is like this:
services:
traefik:
image: "traefik:v3.0"
container_name: "traefik"
restart: always
command:
- --providers.docker=true
- --providers.docker.watch=true
- --providers.docker.exposedbydefault=false
- --entrypoints.https.address=:443
- --entrypoints.http.address=:80
- --entrypoints.http.http.redirections.entryPoint.to=https
- --entrypoints.http.http.redirections.entryPoint.scheme=https
- --entrypoints.http.http.redirections.entrypoint.permanent=true
- --entrypoints.https.http.tls=true
- --entrypoints.https.http.tls.certresolver=le
- --certificatesresolvers.le.acme.tlschallenge=true
- --certificatesresolvers.le.acme.email=example@example.com
- --certificatesresolvers.le.acme.storage=/letsencrypt/acme.json
- --log
- --api
ports:
- 80:80
- 443:443
volumes:
- traefik:/letsencrypt:rw
- /run/docker.sock:/var/run/docker.sock:ro
networks:
- my_net
pgadmin: # make this accessible from http(s)://11.11.11.11:5050
container_name: pgadmin
image: dpage/pgadmin4:latest
restart: unless-stopped
env_file:
- .env
expose:
- ${PGADMIN_PORT-5050}
environment:
- PGADMIN_CONFIG_SERVER_MODE=False
- SCRIPT_NAME=/pgadmin
volumes:
- pgadmin:/var/lib/pgadmin/
networks:
- my_net
labels:
- traefik.enable=true
- traefik.port=${PGADMIN_PORT-5050}
- traefik.http.routers.pgadmin.rule=Host(`11.11.11.11`)
- traefik.http.routers.pgadmin.entrypoints=https
- traefik.http.routers.pgadmin.tls.certresolver=le
- traefik.http.middlewares.my_net-compress.compress=true
- traefik.http.routers.pgadmin.middlewares=my_net-compress
webapp: # make this accessible from http(s)://11.11.11.11:8090
container_name: webapp
build:
context: ./front
dockerfile: Dockerfile
restart: unless-stopped
expose:
- ${FRONT_PORT-8090}
volumes:
- ./front:/app
- /app/node_modules
networks:
- my_net
labels:
- traefik.enable=true
- traefik.port=${FRONT_PORT-8090}
- traefik.http.routers.qmwebapp.rule=Host(`11.11.11.11`)
- traefik.http.routers.qmwebapp.entrypoints=https
- traefik.http.routers.qmwebapp.tls.certresolver=le
- traefik.http.middlewares.my_net-compress.compress=true
- traefik.http.routers.qmwebapp.middlewares=my_net-compress
I've replaced the real IPv4 address here with "11.11.11.11" just for illustration (assume my server is run on that address). Can anyone tell me where I may be wrong or inattentive?