带命名卷的PostgreSQL不是第二次启动

我正在使用bitnami/postgresql:9.6镜像启动postgresql DB。 我想在容器的重新启动之间保持数据,并使用命名卷。 这是我的docker文件configuration:

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

你能帮我find问题吗? 实际上,我预计这些卷被用于这种目的…可能我犯了一些错误

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