0

I created my app with .yml

services:

  db:
    image: postgres:11-alpine
    environment:
      POSTGRES_DB: wiki
      POSTGRES_PASSWORD: quantoxrocks
      POSTGRES_USER: wikijs
    logging:
      driver: "none"
    restart: unless-stopped
    volumes:
      - db-data:/var/lib/postgresql/data

  wiki:
    image: ghcr.io/requarks/wiki:2
    depends_on:
      - db
    environment:
      DB_TYPE: postgres
      DB_HOST: db
      DB_PORT: 5432
      DB_USER: wikijs
      DB_PASS: quantoxrocks
      DB_NAME: wiki
    restart: unless-stopped
    ports:
      - "3000:3000"
    
  webserver:
    image: nginx:alpine
    restart: unless-stopped
    tty: true
    ports:
       - "443:443"
       - "80:80"            
    volumes:
      - ./nginx/conf.d:/etc/nginx/conf.d
      - ./ssl:/etc/nginx/ssl        
volumes:
  db-data:

I logged in my db container and want to create database. I have tried at least 10 times and I am sure that password is from the above docker-compose.yml file. It does not work.

docker exec -it wiki_db_1 sh

Next

psql -h wiki_db_1 -U wikijs
Password for user wikijs: 
psql: FATAL:  password authentication failed for user "wikijs"

Why? How can I check any further logs?

1 Answer 1

2

The environment variables for Postgres are only used if there is no database present already when the container starts.

You have a volume mapping of /var/lib/postgresql/data and it's likely that you already have a database there, which was created with different values from the environment variable values.

If you don't have any important data in the existing database, you can delete the volume and Postgres will create a new database with the correct username/password.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for help. I changed 127.0.0.1 to 172.27.0.2(docker IP) in pg_hba.conf ,still I can not log in.
@MarkoGM If you're connecting from inside the database container, then localhost (127.0.0.1) should work and be the default. Try psql -U wikijs

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.