具有命名卷的 PostgreSQL 没有第二次启动

PostgreSQL with named volume isn't starting the second time

我正在使用 bitnami/postgresql:9.6 docker 图像来启动 postgresql 数据库。我想在容器重启之间保留数据,并且我使用了命名卷。这是我的 docker 文件配置:

  postgresql:
    image: 'bitnami/postgresql:9.6'
    ports:
      - 5432
    environment:
      - POSTGRESQL_REPLICATION_MODE=<name>
      - POSTGRESQL_REPLICATION_USER=<name>
      - POSTGRESQL_REPLICATION_PASSWORD=<name>
      - POSTGRESQL_USERNAME=<name>
      - POSTGRESQL_PASSWORD=<name>
      - POSTGRESQL_DATABASE=<name>
      - POSTGRES_INITDB_ARGS="--encoding=utf8"
    volumes:
      - volume-postgresql:/bitnami/postgresql/data

    volumes:
      volume-postgresql:

但是当我重新启动容器时出现以下错误:

postgresql  | nami    INFO  Initializing postgresql
postgresql  | Error executing 'postInstallation': initdb: directory "/opt/bitnami/postgresql/data" exists but is not empty
postgresql  | If you want to create a new database system, either remove or empty
postgresql  | the directory "/opt/bitnami/postgresql/data" or run initdb
postgresql  | with an argument other than "/opt/bitnami/postgresql/data".

你能帮我找出问题所在吗?实际上,我预计卷会用于此类目的...可能我做错了什么

好的,看来我用错了目录。基于这个网站 https://hub.docker.com/r/bitnami/postgresql/ 我应该使用 /bitnami 而不是 /bitnami/postgresql/data