Docker-撰写标签有问题
Docker-compose having problems with labels
我正在尝试使用其文档中显示的示例设置 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 文档中找到:
test/docker-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/docker-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
Docker 撰写标签包含在版本 v3.3 中,您 运行 版本 1.17.0
有关详细信息,请参阅 doc。
解决方案:降级到docker-compose v1.16.1.
我确认 metanerd 的回答:
使用
labels:
traefik.backend: "whoami"
traefik.frontend.rule: "Host:whoami.docker.localhost"
有效。
我相信,在 3.3 中,您将标签放在构建 属性 下
例如见下文
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 检查中看到,标签已应用
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"}
升级您的 docker 和 docker - 两者兼备。它将自动修复。
我正在尝试使用其文档中显示的示例设置 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 文档中找到: test/docker-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/docker-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
Docker 撰写标签包含在版本 v3.3 中,您 运行 版本 1.17.0
有关详细信息,请参阅 doc。
解决方案:降级到docker-compose v1.16.1.
我确认 metanerd 的回答:
使用
labels:
traefik.backend: "whoami"
traefik.frontend.rule: "Host:whoami.docker.localhost"
有效。
我相信,在 3.3 中,您将标签放在构建 属性 下 例如见下文
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 检查中看到,标签已应用
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"}
升级您的 docker 和 docker - 两者兼备。它将自动修复。