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"