ERROR: In file './docker-compose.yml', service 'volumes' must be a mapping not an array

Sudarshan picture Sudarshan · Sep 18, 2016 · Viewed 78k times · Source

My docker-compose.yml looks like the below and I am trying to follow the compose file from the docker registry documentation here. When i run docker-compose up I get the below error.

ERROR: In file './docker-compose.yml', service 'volumes' must be a mapping not an array.

registry:
  restart: always
  image: sudarshan/registry
  ports:
    - 5000:5000
environment:
  REGISTRY_HTTP_TLS_CERTIFICATE: /certs/domain.crt
  REGISTRY_HTTP_TLS_KEY: /certs/domain.key
  REGISTRY_AUTH: silly
  REGISTRY_AUTH_SILLY_SERVICE: SILLY_SERVICE
  REGISTRY_AUTH_SILLY_REALM: SILLY_REALM
volumes:
  - /usr/certs:/certs

My docker version is

Docker version 1.12.1, build 23cf638

docker-compose version is

docker-compose version 1.7.1, build 0a9ab35

Running on Ubuntu 16.04

EDIT:

Also tried

registry:
  restart: always
  image: sudarshan/registry
  ports:
    - 5000:5000
environment:
  REGISTRY_HTTP_TLS_CERTIFICATE: /certs/domain.crt
  REGISTRY_HTTP_TLS_KEY: /certs/domain.key
  REGISTRY_AUTH: silly
  REGISTRY_AUTH_SILLY_SERVICE: SILLY_SERVICE
  REGISTRY_AUTH_SILLY_REALM: SILLY_REALM
volumes:
    - /usr/certs:/certs

Answer

JesusTinoco picture JesusTinoco · Sep 18, 2016

The thing is that you are not indenting the fields properly. Your docker-compose should look like the below:

registry:
  restart: always
  image: sudarshan/registry
  ports:
    - 5000:5000
  environment:
    REGISTRY_HTTP_TLS_CERTIFICATE: /certs/domain.crt
    REGISTRY_HTTP_TLS_KEY: /certs/domain.key
    REGISTRY_AUTH: silly
    REGISTRY_AUTH_SILLY_SERVICE: SILLY_SERVICE
    REGISTRY_AUTH_SILLY_REALM: SILLY_REALM
  volumes:
    - /usr/certs:/certs