How to browse to a specific container behind a load balancer

I have two containers from two images on which I am doing A/B testing. I have traefik load balancer configured to do that. I would also like to hit the containers with the specific image. The containers are assigned a different port on the host so one thing I could do is look that up and the hit the specific port so for example, http://example:32763. However if I am tearing and bringing this up over and over those ports change requiring me to keep looking them up.

I tried adding additional labels (example-foo and example-bar), but those too appear to be load balancing between the two. How can I do this?

Example docker-compose.yml

foo:
    image: foo
    build:
      context: ./foo
    ports:
      - "80"
    labels:
      - "traefik.http.routers.foo.rule=Host(`example`)"
      - "traefik.http.routers.foo.rule=Host(`example-foo`)"
      - "traefik.http.services.foo.loadbalancer.server.port=80"
      - "traefik.http.services.foo.loadbalancer.sticky=true"
      - "traefik.http.services.foo.loadbalancer.sticky.cookie.name=foobar"
bar:
    image: bar
    build:
      context: ./bar
    ports:
      - "80"
    labels:
      - "traefik.http.routers.foo.rule=Host(`example`)"
      - "traefik.http.routers.foo.rule=Host(`example-bar`)"
      - "traefik.http.services.foo.loadbalancer.server.port=80"
      - "traefik.http.services.foo.loadbalancer.sticky=true"
      - "traefik.http.services.foo.loadbalancer.sticky.cookie.name=foobar"
  

Sorry, I don't understand from your description what you are trying to achieve. The point of load balancing is that the requests are spread between the targets. If you always need a particular target than expose just this target separately without load balancing. Repeat for others.

Sorry, maybe I wasn't clear. I am doing load balancing, but I need to hit a particular target for debugging.

Gotcha. Try this:

version: '3.7'
services:
  reverse-proxy:
    image: traefik:v2.0
    command: 
      - --providers.docker
      - --entryPoints.web.address=:80
    ports:
      - "80:80"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
  web1:
    image: containous/whoami
    labels:
      - "traefik.http.routers.lb.rule=Host(`example.com`)"
      - "traefik.http.routers.lb.service=lb"
      - "traefik.http.services.lb.loadbalancer.server.port=80"

      - "traefik.http.routers.foo.rule=Host(`foo.example.com`)"
      - "traefik.http.routers.foo.service=foo"
      - "traefik.http.services.foo.loadbalancer.server.port=80"
  web2:
    image: containous/whoami
    labels:
      - "traefik.http.routers.lb.rule=Host(`example.com`)"
      - "traefik.http.routers.lb.service=lb"
      - "traefik.http.services.lb.loadbalancer.server.port=80"

      - "traefik.http.routers.bar.rule=Host(`bar.example.com`)"
      - "traefik.http.routers.bar.service=bar"
      - "traefik.http.services.bar.loadbalancer.server.port=80"

That does work, thank you.