I've wrote a docker-compose file to bring up a traefik container, using network_mode="host". But it keeps raising an error:
level=error msg="service "traefik-traefik" error: port is missing" providerName=docker
It is just docker and docker-compose, in a single node vps, and I am not using swarm. The traefik version is 2.5
Here is my docker-compose.yaml:
version: '3.7'
services:
traefik:
network_mode: "host"
build:
context: .
dockerfile: Dockerfile.traefik
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./traefik-public-certificates:/certificates"
labels:
- "traefik.enable=true"
- "traefik.http.routers.dashboard.rule=Host(`msite.mdomain`)"
- "traefik.http.routers.dashboard.tls=true"
- "traefik.http.routers.dashboard.tls.certresolver=letsencrypt"
- "traefik.http.routers.dashboard.service=api@internal"
- "traefik.http.routers.dashboard.middlewares=auth"
- "traefik.http.middlewares.auth.basicauth.users=suser:spass"
volumes:
traefik-public-certificates:
traefik.toml:
[entryPoints]
[entryPoints.web]
address = ":80"
[entryPoints.web.http]
[entryPoints.web.http.redirections]
[entryPoints.web.http.redirections.entryPoint]
to = "websecure"
scheme = "https"
[entryPoints.websecure]
address = ":443"
[accessLog]
[api]
dashboard = true
[providers]
[providers.docker]
exposedByDefault = false
[certificatesResolvers.letsencrypt.acme]
email = "msite@mdmain.com"
storage = "/certificates/acme.json"
[certificatesResolvers.letsencrypt.acme.httpChallenge]
entryPoint = "web"
As far as I know, the network_mode = "host" removes the dependency to declare the port and the network in the docker-compose.yaml. Any help is welcome.