How to put traefik v2.0 in front of containers from different images?

I am trying to do A/B testing on two images and I can't figure out how to load balance between the two. I have seen various examples which talk about multiple instances of one image, but I have more than one. When I try go to example.com it just hits web1 (maybe because it's defined first, I am not sure). I have tried many different clients and it always goes to web1. Has anybody gotten something like this to work? I'd appreciate any help.

Here is what my docker-compose.yml looks like.

version: '3.7'
services:
  reverse-proxy:
    image: traefik:v2.0
    command: --api.insecure=true --providers.docker
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
  web1:
    image: web1
    build:
      context: ./web1
    ports:
      - "80"
    labels:
      - "traefik.http.routers.web1.rule=Host(`example.com`)"
      - "traefik.http.services.web1.loadbalancer.server.port=80"
      - "traefik.http.services.web1.loadbalancer.sticky=true"
  web2:
    image: web2
    build:
      context: ./web2
    ports:
      - "80"
    labels:
      - "traefik.http.routers.web2.rule=Host(`example.com`)"
      - "traefik.http.services.web2.loadbalancer.server.port=80"
      - "traefik.http.services.web2.loadbalancer.sticky=true"

Try this:

version: '3.7'
services:
  reverse-proxy:
    image: traefik:v2.0
    command: --api.insecure=true --providers.docker
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
  web1:
    image: web1
    build:
      context: ./web1
    ports:
      - "80"
    labels:
      - "traefik.http.routers.web1.rule=Host(`example.com`)"
      - "traefik.http.services.web1.loadbalancer.server.port=80"
      - "traefik.http.services.web1.loadbalancer.sticky=true"
      - "traefik.http.services.web1.loadbalancer.sticky.cookie.name=foobar"
  web2:
    image: web2
    build:
      context: ./web2
    ports:
      - "80"
    labels:
      - "traefik.http.routers.web1.rule=Host(`example.com`)"
      - "traefik.http.services.web1.loadbalancer.server.port=80"
      - "traefik.http.services.web1.loadbalancer.sticky=true"
      - "traefik.http.services.web1.loadbalancer.sticky.cookie.name=foobar"

@zespri thank you! that appears to be working. I don't understand why web2 labels use web1 in their name. I must not be understanding how this works.

In your example you created two separate loadbalancers, each of which would load balance against a single service. The rule that had happend to match first worked, and that router / loadbalancer was used. The second one was never reachable because of that.

Ah, that makes sense now. Thank you for explaining.