首页 > 解决方案 > 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

标签: postgresqldocker

解决方案


Try doing docker-compose down to remove the container and do again docker-compose up, you can get more help from this link


推荐阅读