How do i add external service using labels/command?

Hi I'm running Traefik 2.9.6 using docker-compose.

How do I add a remote/external (not hosted on the same docker host) service using labels/commands?

I tried to add the following labels to the traefik container but that didn't work

- "traefik.enable=true"
- "traefik.http.routers.test.rule=Host(`test.localhost`)"
- "traefik.http.routers.test.service=test"
- ""
- ""

When I start Traefik and look in the dashboard it dosen't seem to find the test service.

Would you mind sharing your full Traefik static and dynamic config, and docker-compose.yml if used?

You should probably use .url. Do you have provider.docker enabled to read the labels?

I don't have any other config excluding my command section.

    image: "traefik:${TRAEFIK_VERSION}"
    container_name: "traefik"
    restart: unless-stopped
    read_only: true
    mem_limit: 2G
    cpus: 0.75
      - no-new-privileges:true
      - "--log.level=DEBUG"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      # Logs
      - --accesslog.filepath=/logs/access.log
      - --accesslog.format=json
      - --accesslog.fields.defaultMode=keep
      - --accesslog.fields.headers.defaultMode=keep
      - --log.filepath=/logs/traefik.log
      #- --log.format=json
      - "traefik.enable=true"
      - "traefik.http.routers.test.rule=Host(`test.localhost`)"
      - "traefik.http.routers.test.service=test"
      - ""
      - ""
      - TZ=Europe/Stockholm
      - "80:80"
      - "443:443"
      - "8080:8080"
      - ./traefik/logs:/logs

Did you see my comment regarding .url? You should try


Update: Seems you can't use .loadbalancer.server.url in labels, so you need to create a dynamic config file with loadbalancer and load that file via provider.file in your static config.

Thanks that explains why it didn't even show up in the ui or the logs!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.