Search code examples
dockerdocker-composetraefikkatacodakata-containers

Katacode Traefik tutorial error - container not created


I am trying out the Katacoda playground for Load Balance Containers using Traefik - https://www.katacoda.com/courses/traefik/deploy-load-balancer:

Here is the exact Docker compose script in the tutorial to start a Traefik node and 2 test containers:

  image: traefik
  command: --web --docker --docker.domain=docker.localhost --logLevel=DEBUG
  ports:
    - "80:80"
    - "8080:8080"
    - "443:443"
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    - /dev/null:/traefik.toml

machine:
  image: katacoda/docker-http-server
  labels:
    - "traefik.backend=machine-echo"
    - "traefik.frontend.rule=Host:machine-echo.example.com"

echo:
  image: katacoda/docker-http-server:v2
  labels:
    - "traefik.backend=echo"
    - "traefik.frontend.rule=Host:echo-echo.example.com"

I run Docker-Compose command, as given in tutorial:

$ docker-compose up -d
Creating tutorial_traefik_1 ... done
Creating tutorial_echo_1    ... done
Creating tutorial_machine_1 ... done

However when I check the container list, I can see only 2 containers are created. The Traefik container is not created:

$ docker container ls
CONTAINER ID        IMAGE                            COMMAND             CREATED             STATUS              PORTS               NAMES
35e87a3ff6ed        katacoda/docker-http-server      "/app"              11 seconds ago      Up 9 seconds        80/tcp              tutorial_machine_1
a455019d16be        katacoda/docker-http-server:v2   "/app"              11 seconds ago      Up 9 seconds        80/tcp              tutorial_echo_1 

The next step fails too. This may be because the Traefik container is not running:

$ curl -H Host:machine-echo.example.com http://host01
curl: (7) Failed to connect to host01 port 80: Connection refused

Can anyone replicate this tutorial and please let me know the cause and fix for this error?


Solution

  • Just run on this today, you must hardcode traefik version to 1.7.32

    traefik:
      image: traefik:1.7.32
      command: --web --docker --docker.domain=docker.localhost --logLevel=DEBUG
      ports:
        - "80:80"
        - "8080:8080"
        - "443:443"
      volumes:
        - /var/run/docker.sock:/var/run/docker.sock
        - /dev/null:/traefik.toml
    
    machine:
      image: katacoda/docker-http-server
      labels:
        - "traefik.backend=machine-echo"
        - "traefik.frontend.rule=Host:machine-echo.example.com"
    
    echo:
      image: katacoda/docker-http-server:v2
      labels:
        - "traefik.backend=echo"
        - "traefik.frontend.rule=Host:echo-echo.example.com"