title: docker-compose with Django and Postgresql: Password does not match for user "postgres"
body: <p>I am following exactly the django, psql, docker tutorial <a href="https://docs.docker.com/samples/django/" rel="nofollow noreferrer">https://docs.docker.com/samples/django/</a></p>
  <p>and I keep getting the error:</p>
  <pre><code>Password does not match for user &quot;postgres&quot;
  </code></pre>
  <p>and from django I am getting:</p>
  <pre><code>web_1  |   File &quot;/usr/local/lib/python3.9/site-packages/psycopg2/__init__.py&quot;, line 122, in connect
  web_1  |     conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
  web_1  | django.db.utils.OperationalError: FATAL:  password authentication failed for user &quot;postgres&quot;
  </code></pre>
  <p>from Postgresql I am getting</p>
  <pre><code>2021-08-16 06:44:09.563 UTC [1] LOG: starting PostgreSQL 13.4 (Debian 13.4-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
  
  2021-08-16 06:44:09.572 UTC [1] LOG: listening on IPv4 address &quot;0.0.0.0&quot;, port 5432
  
  2021-08-16 06:44:09.581 UTC [1] LOG: listening on IPv6 address &quot;::&quot;, port 5432
  
  2021-08-16 06:44:09.668 UTC [1] LOG: listening on Unix socket &quot;/var/run/postgresql/.s.PGSQL.5432&quot;
  
  2021-08-16 06:44:09.885 UTC [26] LOG: database system was shut down at 2021-08-16 06:37:34 UTC
  
  2021-08-16 06:44:09.960 UTC [1] LOG: database system is ready to accept connections
  
  2021-08-16 06:44:10.942 UTC [33] FATAL: password authentication failed for user &quot;postgres&quot;
  
  2021-08-16 06:44:10.942 UTC [33] DETAIL: Password does not match for user &quot;postgres&quot;.
  
  Connection matched pg_hba.conf line 99: &quot;host all all all md5&quot;
  
  
  
  PostgreSQL Database directory appears to contain a database; Skipping initialization
  </code></pre>
  <p>docker-compose.yml</p>
  <pre><code>        version: &quot;3.9&quot;
          
          services:
            db:
              image: postgres
              volumes:
                - ./data/db:/var/lib/postgresql/data
              environment:
                - POSTGRES_DB=postgres
                - POSTGRES_USER=postgres
                - POSTGRES_PASSWORD=postgres
            web:
              build: .
              command: python manage.py runserver 0.0.0.0:8000
              volumes:
                - .:/code
              ports:
                - &quot;8000:8000&quot;
              depends_on:
                - db
  
  </code></pre>
  <p>Dockerfile</p>
  <pre><code># syntax=docker/dockerfile:1
  FROM python:3
  ENV PYTHONUNBUFFERED=1
  WORKDIR /code
  COPY requirements.txt /code/
  RUN pip install -r requirements.txt
  COPY . /code/
  </code></pre>
  <p>Django database settings</p>
  <pre><code>ALLOWED_HOSTS = ['*']
  
  DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.postgresql',
          'NAME': 'postgres',
          'USER': 'postgres',
          'PASSWORD': 'postgres',
          'HOST': 'db',
          'PORT': 5432,
      }
  }
  </code></pre>
  <p>I think the only thing that is stopping it from working is the psql password not working from django side</p>