我正在尝试使用docker-compose挂载我的postgres.conf和pg_hba.conf,我很难理解为什么它在使用docker-cli运行时可以工作,而不能使用docker-compose运行
下面的docker-compose命令会导致镜像崩溃并出现错误:
/usr/local/bin/docker-entrypoint.sh: line 176: /config_file=/etc/postgresql/postgres.conf: No such file or directorydocker-compose.yml
services:
postgres-master:
image: postgres:11.4
container_name: postgres-master
volumes:
- ./init.sql:/docker-entrypoint-initdb.d/init.sql:ro
- /home/agilob/dockers/pg/data:/var/lib/postgresql/data:rw
- $PWD/pg:/etc/postgresql:rw
- /etc/localtime:/etc/localtime:ro
hostname: 'primary'
environment:
- PGHOST=/tmp
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
- MAX_CONNECTIONS=10
- MAX_WAL_SENDERS=5
- PG_MODE=primary
- PUID=1000
- PGID=1000
ports:
- "5432:5432"
command: 'config_file=/etc/postgresql/postgres.conf hba_file=/etc/postgresql/pg_hba.conf'此命令运行良好:
docker run -d --name some-postgres -v "$PWD/postgres.conf":/etc/postgresql/postgresql.conf postgres -c 'config_file=/etc/postgresql/postgresql.conf'另外,当我删除command:部分并运行相同的docker-compose时:
$ docker-compose -f postgres-compose.yml up -d
Recreating postgres-master ... done
$ docker exec -it postgres-master bash
root@primary:/# cd /etc/postgresql
root@primary:/etc/postgresql# ls
pg_hba.conf postgres.conf这些文件位于/etc/postgres中。
$PWD/pg中的文件存在:
$ ls pg
pg_hba.conf postgres.conf发布于 2019-08-11 18:56:25
下面的代码运行良好:
command: postgres -c config_file='/etc/postgresql/postgres.conf' -c 'hba_file=/etc/postgresql/pg_hba.conf'https://stackoverflow.com/questions/57449025
复制相似问题