Root@vm53200-14:/var/lib/docker/containers/geneious# docker compose up -d volumes Additional property /var/lib/docker/volumes/geneious-db is not allowed

Hi guys,
i wanted to recreate a container.
This is the docker-compose.yml:

Use postgres/example user/password credentials

version: ‘3.1’

services:

  db:
    image: postgres:11-alpine
    restart: always
    volumes:
      - /var/lib/docker/volumes/geneious-db:/var/lib/pgsql/data
    environment:
      POSTGRES_PASSWORD: xxxxxxxxx
      TZ: Europe/Berlin
      POSTGRES_DB: geneious
      PGDATA: /var/lib/postgresql/data
    ports:
      - 5432:5432

volumes:
  /var/lib/docker/volumes/geneious-db:

When i issue “docker compose up -d” i get:
volumes Additional property /var/lib/docker/volumes/geneious-db is not allowed
When i comment the volumes section it runs.
But i need the volume, i’d like to have the database files outside the container.
I remember using this yml-file already several times. I have the impression that there is something left from the these tries, but i don’t know how to get rid off it.
The folder /var/lib/docker/volumes/geneious-db exist.
While googleing i found “docker compose up --remove-orphans”, but i get the same error.
I also found that there are “normal” volumes and “named” ones.
Which are to prefer ?

Bernd

You compose file is mallformed. You are using a bind, which does not require a top-level volumes: declaration as in fact it is not a named volume.

Your top-level volumes declaration ia a) not requred because you bind a host path to a container path and b) is malformed: see compose specification

Just remove the top-level volumes declaration.

Only named volumes are “real” volumes and will be listed by docker volume ls

It is a matter of taste and need whether you use a bind or a named volume. With docker swarm, you only want to use named volumes that are backed by a remote share or a volume plugin that makes the volume available to all nodes.