不能将 traefik 与动态配置文件一起使用
can not use traefik with dynamic configuration file
我正在尝试学习和使用 traefik。
这是我的 docker-compose.yaml:
version: "3"
services:
traefik:
image: "traefik:v2.0"
container_name: "traefik"
ports:
- "80:80"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- ./traefik:/etc/traefik
- ./docker:/etc/docker
whoami:
image: "containous/whoami"
container_name: "whoami"
这是我的 traefik.toml:
[entryPoints]
[entryPoints.web]
address = ":80"
[providers]
[providers.file]
filename = "/etc/docker/dynamic_conf.toml"
[providers.docker]
exposedByDefault = false
[api]
insecure = true
这是我的 dynamic_conf.toml:
[http]
[http.routers]
[http.routers.whoami]
rule = "Host(`whoami.localhost`)"
entrypoints = "web"
service = "whoami"
但是当我构建图像并运行它时,我得到一个错误:
Cannot start the provider *file.Provider: toml: cannot load TOML value of type string into a Go slice
截图:traefik errors
找不到原因,我找了一下,我改了
filename = "/etc/docker/dynamic_conf.toml"
到
filename = ["/etc/docker/dynamic_conf.toml"]
我正在尝试学习和使用 traefik。 这是我的 docker-compose.yaml:
version: "3"
services:
traefik:
image: "traefik:v2.0"
container_name: "traefik"
ports:
- "80:80"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- ./traefik:/etc/traefik
- ./docker:/etc/docker
whoami:
image: "containous/whoami"
container_name: "whoami"
这是我的 traefik.toml:
[entryPoints]
[entryPoints.web]
address = ":80"
[providers]
[providers.file]
filename = "/etc/docker/dynamic_conf.toml"
[providers.docker]
exposedByDefault = false
[api]
insecure = true
这是我的 dynamic_conf.toml:
[http]
[http.routers]
[http.routers.whoami]
rule = "Host(`whoami.localhost`)"
entrypoints = "web"
service = "whoami"
但是当我构建图像并运行它时,我得到一个错误:
Cannot start the provider *file.Provider: toml: cannot load TOML value of type string into a Go slice
截图:traefik errors
找不到原因,我找了一下,我改了
filename = "/etc/docker/dynamic_conf.toml"
到
filename = ["/etc/docker/dynamic_conf.toml"]