How to fix docker-compose: services.my-service Additional property volume is not allowed

Deutsch English

Problem:

When you try to start your docker-compose based service using

docker_compose_up.sh
docker-compose up

you see the following error message

docker_compose_volume_error.txt
services.my-service Additional property volume is not allowed

with a config such as

docker-compose-volume-typo.yml
services:
  mariadb:
    image: 'mariadb:latest'
    environment:
      - MYSQL_ALLOW_EMPTY_PASSWORD=yes
      - MYSQL_DATABASE=redmine
    volume:
      - './mariadb_data:/var/lib/mysql'

Solution

You’ve mis-spelled volume: - it always needs to be called volumes: even if there is only a single volume:

docker-compose-volume-fixed.yml
services:
  mariadb:
    image: 'mariadb:latest'
    environment:
      - MYSQL_ALLOW_EMPTY_PASSWORD=yes
      - MYSQL_DATABASE=redmine
    volumes:
      - './mariadb_data:/var/lib/mysql'

Check out similar posts by category: Docker