0

我正在尝试使用 Traefik 的负载平衡容器的 Katacoda 游乐场- https://www.katacoda.com/courses/traefik/deploy-load-balancer

这是教程中启动 Traefik 节点和 2 个测试容器的确切 Docker 撰写脚本:

  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"

我运行 Docker-Compose 命令,如教程中所述:

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

但是,当我检查容器列表时,我只能看到创建了 2 个容器。Traefik 容器未创建:

$ 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 

下一步也失败了。这可能是因为 Traefik 容器没有运行:

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

任何人都可以复制本教程,请让我知道原因并修复此错误吗?

4

1 回答 1

2

今天就在这个上运行,你必须将 traefik 版本硬编码为 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"
于 2021-10-06T21:36:46.517 回答