【发布时间】:2019-06-18 22:10:37
【问题描述】:
postgresDocker imagesays的文档如下关于env varPOSTGRES_DB:
此可选环境变量可用于为首次启动映像时创建的默认数据库定义不同的名称。如果未指定,则使用 POSTGRES_USER 的值。
我发现这根本不是真的。例如,使用此配置:
version: '3.7'
services:
db:
image: postgres:11.3-alpine
restart: always
container_name: store
volumes:
- postgres_data:/var/lib/postgresql/data/
ports:
- 5432:5432
environment:
- POSTGRES_USER=custom
- POSTGRES_DB=customname
- POSTGRES_PASSWORD_FILE=/run/secrets/db_password
secrets:
- db_password
volumes:
postgres_data:
secrets:
db_password:
file: config/.secrets.db_password
默认数据库名为postgres,而不是我指定的customname:
$ docker exec -it store psql -U custom customname
psql: FATAL: database customname does not exist
$ docker exec -it store psql -U custom postgres
psql (11.3)
Type help for help.
postgres=# ^D
我是否遗漏了一些明显的东西?
【问题讨论】:
标签: postgresql docker docker-compose