randal
randal

Reputation: 1362

Docker postgress User "postgres" has no password assigned

I keep getting

User "postgres" has no password assigned.

updated

enter image description here

.env

POSTGRES_PORT=5432
POSTGRES_DB=demo_db2
POSTGRES_USER=postgres
POSTGRES_PASSWORD=password

Even though the postgres password is set.

I'm trying to use the same variables from the following command

docker run --name demo4 -e POSTGRES_PASSWORD=password -d postgres

Could this be an issue with volumes ? im very confused.

I ran this command as well

 docker run -it --rm --name demo4 -p 5432:5432 -e POSTGRES_PASSWORD=password -e POSTGRES_USER=postgress postgres:9.4

docker-compose.yml

# docker-compose.yml
version: "3"
services:
  app:
    build: .
    depends_on:
      - database
    ports:
      - 8000:8000
    environment:
      - POSTGRES_HOST=database
  database:
    image: postgres:9.6.8-alpine
    volumes:
      - pgdata:/var/lib/postgresql/pgdata
    ports:
      - 8002:5432
  react_client:
      build:
        context: ./client
        dockerfile: Dockerfile
      image: react_client
      working_dir: /home/node/app/client
      volumes:
        - ./:/home/node/app
      ports:
        - 8001:8001
      env_file:
        - ./client/.env
volumes:
  pgdata:

Upvotes: 0

Views: 1257

Answers (1)

Exadra37
Exadra37

Reputation: 13104

You are missing the inclusion of the .env file...

Docker composer:

database:
  environment:
    - ENV_VAR=VALUE

or

database:
  env_file:
    - .env

Plain Docker:

docker run options --env ENV_VAR=VALUE ...

or

docker run options --env-file .env ...`

Upvotes: 1

Related Questions