Traefik as a proxy for Docker container with host machines network -


i set following scenario:

  • one physical machine docker containers
  • traefik in container network backend
  • another container using host machines network (network_mode: host)

traefik finds container , adds ip address 127.0.0.1 not accessible traefik container (different network/bridge).

docker-compose.yml:

version: '3' services:     traefik:         image: traefik         ports:             - "80:80"             - "443:443"         volumes:             - /var/run/docker.sock:/var/run/docker.sock             - ./traefik.toml:/etc/traefik/traefik.toml         networks:             - backend      app:          image: my_app          labels:              - "traefik.enable=true"              - "traefik.frontend.rule=host:myapp.example"              - "traefik.port=8080"          network_mode: host networks:     backend:         driver: bridge 

the app container added

server      url                     weight  server-app  http://127.0.0.1:8080   0 load balancer: wrr 

of course can access app http://127.0.0.1:8080 on host machine or http://$host_ip:8080 traefik container.

can somehow convince traefik use ip container?

thanks!

without common docker network, traefik won't able route container. since you're using host networking, there's little need traefik proxy container, access directly. or if need access through proxy, place on backend network. if need ports published on host , others proxied through traefik, place on backend network , publish ports need publish, rather using host network directly.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -