Traefik V2 labels for docker-compose

Hello everyone,

I am a developer student and I am learning to use Docker and Traefik. I installed Docker and Traefik on my macbook but I do not know how to connect my Docker container with Traefik.
I have red that I need labels to create a connection but I do not know how to do this.

Could anyone tell me which labels I need to create a connection? I have searched online but I could not find good results.

I do not want to use https right now so I do not need a certificate.

Hello @Vlame,

There are some basic examples on the documentation.

Here is my simplest docker-compose example that uses labels:

version: '3.6'

services:
  traefik:
    image: traefik:v2.6
    command:
      - --providers.docker
    ports:
      - "80:80"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

  whoami:
    image: traefik/whoami
    labels:
      traefik.http.routers.whoami.rule: Host(`whoami.localhost`)

Hope it helps :slight_smile:

Hello @tommoulard. Thanks for your answer! I will look at this.