6

I'm trying to setup Traefik reverse proxy using example shown in their docs. When I try to bring up 'whoami' service I get following error:

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

Example docker-compose.yml can be found in Traefik docs: 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

Using following docker and docker-compose versions:

Docker version 17.09.0-ce, build afdb6d4
docker-compose version 1.17.0, build ac53b73
metalcamp
  • 526
  • 1
  • 6
  • 14

5 Answers5

3

Solution: downgrade to docker-compose v1.16.1.

metalcamp
  • 526
  • 1
  • 6
  • 14
1

Docker compose labels is included in version v3.3 and you're running version 1.17.0

Please see the doc for more info.

juanlumn
  • 6,155
  • 2
  • 30
  • 39
  • 1
    docker-compose 1.17.0 is the latest release: https://github.com/docker/compose/releases/ Also, I tried changing version of docker-compose.yml to version: '3.3' with no success. – metalcamp Nov 03 '17 at 11:45
  • 3
    I changed the syntax to this kind of style: ` labels: traefik.backend: "portainer" ` from ` labels: - "traefik.backend=portainer" ` and it worked for me – metanerd Nov 12 '17 at 12:35
1

I confirm metanerd's answer:

using

labels:
  traefik.backend: "whoami"
  traefik.frontend.rule: "Host:whoami.docker.localhost"

works.

scinart
  • 457
  • 2
  • 9
1

I believe, with 3.3, you put the tags under the build property e.g. See below

version: '3.3'
services:
  sample-app:
    image: ${IMAGE_NAME}
    build:
      context: .
      labels:
        org.label-schema.build-date: ${BUILD_DATE}
        org.label-schema.commit: ${COMMIT}
...

You can see from docker inspect, that the labels have been applied

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"}

See https://docs.docker.com/compose/compose-file/

mlo55
  • 6,663
  • 6
  • 33
  • 26
  • They can also be at the runtime level (container vs image). Make sure your file "version" is >= '3.3'. – ColinM Oct 26 '19 at 02:44
1

Upgrade your docker and docker-compose both. It will be fixed automatically.

Umar Asghar
  • 3,808
  • 1
  • 36
  • 32