0

Running docker-compose -f production.yml up will eventually return:

postgres_1      |   Connection matched pg_hba.conf line 95: "host all all all md5"
django_1        | PostgreSQL is unavailable (sleeping)...
postgres_1      | 2018-03-21 07:48:35.575 UTC [120] FATAL:  password authentication failed for user "DbUsErName"
postgres_1      | 2018-03-21 07:48:35.575 UTC [120] DETAIL:  Password does not match for user "DbUsErName".  

In my .envs/.production/.postgres I have my envs laid out in this manner:

# PostgreSQL
# ------------------------------------------------------------------------------
POSTGRES_DB=luup
POSTGRES_USER=DbUsErName
POSTGRES_PASSWORD=myVeryYLongPW

Before the error above, the terminal will also output:

celeryworker_1  | /entrypoint.sh: line 13: POSTGRES_USER: parameter not set  

However it does appear it's being set in this file within compose/production/django/entrypoint.sh:

set -o errexit
set -o pipefail
set -o nounset


cmd="$@"

if [ -z "${POSTGRES_USER}" ]; then
    # the official postgres image uses 'postgres' as default user if not set explictly.
    export POSTGRES_USER=postgres
fi
export DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}"

I haven't touched much postgres configs since I started the project as this is an attempt to only get it up and running on Heroku. So I haven't gone into psql.

What do I need to do to get this up and running?

Please let me know if additional information is needed.

Edit--production.yml:

version: '2'

volumes:
  postgres_data: {}
  postgres_backup: {}
  caddy: {}

services:
  django: &django
    build:
      context: .
      dockerfile: ./compose/production/django/Dockerfile
    depends_on:
      - postgres
      - redis
    env_file:
      - ./.envs/.production/.django
      - ./.envs/.production/.postgres
      - ./.envs/.production/.celery
    command: /gunicorn.sh

  postgres:
    build:
      context: .
      dockerfile: ./compose/production/postgres/Dockerfile
    volumes:
      - postgres_data:/var/lib/postgresql/data
      - postgres_backup:/backups
    env_file:
      - ./.envs/.production/.postgres

  caddy:
    build:
      context: .
      dockerfile: ./compose/production/caddy/Dockerfile
    depends_on:
      - django
    volumes:
      - caddy:/root/.caddy
    env_file:
      - ./.envs/.production/.caddy
    ports:
      - "0.0.0.0:80:80"
      - "0.0.0.0:443:443"

  redis:
    image: redis:3.0

  celeryworker:
    <<: *django
    depends_on:
     - postgres
     - redis
    env_file:
      - ./.envs/.production/.celery
    command: /start-celeryworker.sh

  celerybeat:
    <<: *django
    depends_on:
      - postgres
      - redis
    env_file:
      - ./.envs/.production/.celery
    command: /start-celerybeat.sh
8
  • Can you show your production.yml file? Commented Mar 21, 2018 at 8:04
  • @Quba added now Commented Mar 21, 2018 at 8:07
  • Have you ran your postgres before with different credentials (eg. dev env). If so it is possible that postgres creates user only on the first start and then it does not check if env variables had changed. If so, can you try to rebuild postgres? Commented Mar 21, 2018 at 8:13
  • @Quba actually, I'm not sure I have. When I try running docker-compose -f local.yml run postgres psql, I am returned: psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?. My understanding is that this means it has not been built? How would I go about building it in Docker? Commented Mar 21, 2018 at 8:17
  • 1
    try: docker-compose stop postgres docker-compose rm postgres docker-compose -f production.yml up Commented Mar 21, 2018 at 8:34

1 Answer 1

3

Postgres container creates a user from env variables on the first run. So in order to have it with new values (production username and password), You probably have to rebuild that.

  • docker-compose stop postgres
  • docker-compose rm postgres
  • docker-compose -f production.yml up
Sign up to request clarification or add additional context in comments.

1 Comment

Is there a way to avoid having to do this every time i "re-up"?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.