我尝试使用其文档中显示的示例设置Traefik反向代理。当我试图提起'whoami'服务我得到以下错误:
Creating test_whoami_1 ...
ERROR: for test_whoami_1 dictionary update sequence element #0 has length 22; 2 is required
ERROR: for whoami dictionary update sequence element #0 has length 22; 2 is required
Traceback (most recent call last):
File "bin/docker-compose", line 6, in <module>
File "compose/cli/main.py", line 68, in main
File "compose/cli/main.py", line 121, in perform_command
File "compose/cli/main.py", line 952, in up
File "compose/project.py", line 455, in up
File "compose/parallel.py", line 70, in parallel_execute
ValueError: dictionary update sequence element #0 has length 22; 2 is required
Failed to execute script docker-compose
示例docker-compose.yml可以在Traefik docs中找到: 测试/搬运工-compose.yml
version: '3.3'
services:
whoami:
image: emilevauge/whoami
networks:
- web
labels:
- "traefik.backend=whoami"
- "traefik.frontend.rule=Host:whoami.docker.localhost"
networks:
web:
external:
name: traefik_webgateway
traefik /搬运工-compose.yml
version: '3.3'
services:
proxy:
image: traefik:1.4.1
restart: always
ports:
- 80:80
- 8080:8080
command: --web --docker --docker.domain=docker.localhost --logLevel=DEBUG
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "./traefik.toml:/traefik.toml"
container_name: traefik
networks:
webgateway:
driver: bridge
使用以下docker和docker-compose版本:
Docker version 17.09.0-ce, build afdb6d4
docker-compose version 1.17.0, build ac53b73
答案 0 :(得分:2)
解决方案:降级到docker-compose v1.16.1。
答案 1 :(得分:1)
我确认metanerd的回答:
使用
labels:
traefik.backend: "whoami"
traefik.frontend.rule: "Host:whoami.docker.localhost"
有效。
答案 2 :(得分:1)
同时升级docker和docker-compose。它会自动修复。
答案 3 :(得分:0)
Docker撰写标签包含在v3.3版本中,您正在运行版本1.17.0
请参阅doc了解详情。
答案 4 :(得分:0)
我相信在3.3版本中,您可以将标签放在build属性下 例如见下文
version: '3.3'
services:
sample-app:
image: ${IMAGE_NAME}
build:
context: .
labels:
org.label-schema.build-date: ${BUILD_DATE}
org.label-schema.commit: ${COMMIT}
...
您可以从docker inspect中看到标签已被应用
docker inspect --format='{{json .Config.Labels}}' blah/sample-app
{"org.label-schema.build-date":"2019-05-24-10-36-22","org.label-schema.commit":"2cc11a2"}