postgresql - docker compose ignoring env vars when creating the container for postgres
问题描述
I always get role x does not exist which means the db was created with the default username and my env vars was ignored, any idea whats going on here?
Docker-compose.yml
version: '3.1'
services:
PostgreSQL:
container_name: db-name
image: postgres:12
restart: always
environment:
POSTGRES_PASSWORD: ${PG_PASSWORD}
POSTGRES_USER: ${PG_USERNAME}
POSTGRES_DB: ${PG_DB_NAME}
volumes:
- ./postgres-data:/var/lib/postgresql/data
ports:
- 5432:5432
When I look in kitematic I see the correct env variables and values, but nothing is taking in consideration by the db
解决方案
Try doing docker-compose down to remove the container and do again docker-compose up, you can get more help from this link
推荐阅读
- python - 使用 auto-py-to-exe 将 .py 转换为 .exe 时遇到问题
- firebase - Firestore:无效的文档参考。文档引用必须有偶数个段,
- python - 在烧瓶 api 中加载泡菜
- node.js - 如何覆盖 BigQuery 方法调用的默认超时
- python - 加载具有透明背景的图像
- angular - 如何动态地将函数传递给角度forkJoin()?
- input - 如何使用赛普拉斯将文本框中的值存储在另一个变量中
- java - 如何使用 Maven 依赖插件将多个依赖项复制到多个文件夹
- ruby-on-rails - 如何在rails错误中使用参数进行翻译?
- spring-boot - 有没有办法在 Spring Boot 中进行 JSON 转换,类似于 MuleSoft Dataweave 操作?