Docker container with multiple ports

Hello All,

I'm attempting to run a docker run command with the same parameters with Traefik. That I'm trying to run is this https://github.com/mediagis/nominatim-docker/tree/master/3.4. I have a copy of this running on a different server so it does work.

The application needs 2 ports exposed 5432 and 7070. I have port 7070 going using traefik, but I dont know where or how to expose port 5432 using the yml file. Both have to be pointing to the same container.

Can someone point me in the right direction?

Hello,

you don't have to create file for that, you just need to creates several routers and services.


  app:
    image: your-image
    labels:
      - "traefik.enable=true"
      
      - "traefik.http.routers.foo.rule=Host(`my.domain.com`)"
      - "traefik.http.routers.foo.entrypoints=ep1"
      - "traefik.http.routers.foo.service=svc_foo"

      - "traefik.http.services.svc_foo.loadbalancer.server.port=5432"
      
      - "traefik.http.routers.bar.rule=Host(`my.domain.com`)"
      - "traefik.http.routers.bar.entrypoints=ep2"
      - "traefik.http.routers.bar.service=svc_bar"

      - "traefik.http.services.svc_bar.loadbalancer.server.port=7070"
2 Likes

This helped me. Thank you!

Maybe this could be added to the documentation? There is not a single example of a real world traefik configuration where multiple services are deployed and competing for the same ports or publishing multiple ports. The section on this is 2 lines.