How to make 127.0.0.1:9080 reachable for docker traefik?

Hi all

I am running Traefik inside a docker container, the image is from https://hub.docker.com/_/traefik.
Now, I have a running container:

nginx:mainline-alpine "/bin/sh -c 'envsubs…" 3 hours ago Up 3 hours 127.0.0.1:9080->9080/tcp, 80/tcp, 127.0.0.1:9443->9443/tcp mailcow_nginx-mailcow_1

that I would to include into Traefik. The Configuration of the mailcow_nginx-mailcow_1 service is:

 [http]
  # Add the router
  [http.routers]
    [http.routers.mail]
      service = "service-mailcow"
      rule = "Host(`mail.example.io`)"

    [http.routers.mail.tls]
      certResolver = "sslresolver"

    # Add the service
    [http.services]
      [http.services.service-mailcow]
        [http.services.service-mailcow.loadBalancer]
          [[http.services.service-mailcow.loadBalancer.servers]]
            url = "http://127.0.0.1:9080/"

when calling https://mail.example.io in the browser, the service is not reachable. I think the problem is, that Traefik has not access to http://127.0.0.1.

The Traefik container has been started as follows:

version: "3.7"

#----------------------------------------------------------------#
# Network                                                        #
#----------------------------------------------------------------#
networks:
  edge-router:
    external: true

#----------------------------------------------------------------#
# Router                                                         #
#----------------------------------------------------------------#
services:
  traefik:
    image: "traefik:v2.2"
    container_name: "traefik"
    restart: always
    networks:
      - edge-router
    ports:
      - "80:80"
      - "443:443"
      # The Web UI (enabled by --api.insecure=true)
      - "8080:8080"
    volumes:
      - ./traefik.toml:/etc/traefik/traefik.toml
      - ./letsencrypt:/letsencrypt
      - ./routing:/etc/routing/
      - /var/run/docker.sock:/var/run/docker.sock:ro

My question is, how to make http://127.0.0.1:9080/ reachable for Traefik?

Thanks

The best advise is, don't do that. Use the docker provider and let docker and traefik handle it.
Your configuration would be a set of labels on your container. https://docs.traefik.io/providers/docker/

If you really must(cannot stop this container for $REASON) then you need to use either the local hosts IP (not localhost) or the docker router ip(this is the default route when you run a container, ip route list match 0.0.0.0).

1 Like

Thanks so much for your advice.