错误信息:
postgres_1 | The files belonging to this database system will be owned by user "postgres".
postgres_1 | This user must also own the server process.
postgres_1 |
postgres_1 | The database cluster will be initialized with locale "en_US.utf8".
postgres_1 | The default database encoding has accordingly been set to "UTF8".
postgres_1 | The default text search configuration will be set to "english".
postgres_1 |
postgres_1 | Data page checksums are disabled.
postgres_1 |
postgres_1 | fixing permissions on existing directory /var/lib/postgresql/data ... ok
postgres_1 | creating subdirectories ... ok
postgres_1 | selecting default max_connections ... 20
postgres_1 | selecting default shared_buffers ... 400kB
postgres_1 | selecting dynamic shared memory implementation ... posix
postgres_1 | creating configuration files ... ok
postgres_1 | 2019-01-22 16:57:37.016 UTC [79] FATAL: data directory "/var/lib/postgresql/data" has wrong ownership
postgres_1 | 2019-01-22 16:57:37.016 UTC [79] HINT: The server must be started by the user that owns the data directory.
postgres_1 | child process exited with exit code 1
postgres_1 | initdb: removing contents of data directory "/var/lib/postgresql/data"
postgres_1 | running bootstrap script ... kibati-docker_postgres_1 exited with code 1
我到处搜索,尝试了所有方法,但问题仍未解决...
我尝试的是:
- 使用
docker volume create --name postgres -d local
命令创建Docker卷,并在我的 docker-compose.yml 文件中使用它
docker-compose.yml 文件内容:
version: '2'
services:
postgres:
image: postgres:latest
ports:
- "5432:5432"
volumes:
- postgres:/var/lib/postgresql/data
networks:
internal_ip:
ipv4_address: 192.168.1.2
volumes:
postgres:
external: true
- 在docker compose中直接添加卷
卷示例
volumes:
postgres:
driver: local
- 使用相对或绝对Windows路径
- 为不同的PostgreSQL文件夹(conf,data...)声明多个卷
我尝试了docker compose down,重新启动计算机,删除映像,但仍然出现相同的错误。
我已经勾选了Docker设置中的Shared Drive框。
我尝试过以下方法:
https://glennsarti.github.io/blog/puppet-in-docker/
https://github.com/docker-library/postgres/issues/435
http://www.lukaszewczak.com/2016/09/run-postgresql-using-docker-with.html
https://gdevops.gitlab.io/tuto_docker/tutoriels/postgresql/postgresql.html
https://devask.cz/questions/48645804/mount-postgres-data-to-windows-host-directory
有没有人有一个可行的解决方案?如果我找到了什么,我会继续让它工作,并更新帖子。
提前致谢。