从昨天开始,我尝试在Windows(Bootcamp MacBook Pro)上启动docker项目,而我只剩下一个问题:PostgreSQL映像。
错误消息:
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
样品量
volumes:
postgres:
driver: local
我试图docker整理,重启计算机,删除图像,没有任何变化,相同的错误。
我已经在Docker Settings中选中了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
有人可以作为工作解决方案吗?我将继续使其工作,并在发现某事后更新帖子。
谢谢。
答案 0 :(得分:2)
container_name: postgresql
image: postgres:latest
environment:
POSTGRES_PASSWORD: postgres
# volumes:
# - "./database:/var/lib/postgresql/data/"
ports:
- "5432:5432"
评论卷 这种解决方法可以解决问题并在Windows上工作,我必须在Mac上重新使用这两行,但这是目前最简单的方法,直到docker windows或posgres docker推送某些真正的解决方案
答案 1 :(得分:2)
我终于弄清楚了当我尝试将卷用于PostgreSQL数据时出了什么问题。
我不知道我们使用了docker-compose.override.yml
,它用Windows路径声明了一个卷。
因此,这是一个在Windows的Docker上安装PostgreSQL并具有持久数据的可行解决方案:
version: '2'
services:
postgres:
image: postgres:11.5
ports:
- 5432:5432
volumes:
- pgdata:/var/lib/postgresql/data
- pgconf:/etc/postgresql
- pglog:/var/log/postgresql
volumes:
pgdata:
driver: local
pgconf:
driver: local
pglog:
driver: local
(无需其他命令)