title: Dockerizing a django postgres application getting password authentication failed for user "root" Role "root" does not exist
body: <p>Hi i am dockerizing my django postgres application ,whereas i am specifying user as admin but still i am getting connected to postgres db as root and getting errors.</p>
  <p><strong>DockerFile</strong></p>
  <pre><code>FROM ubuntu:20.04
  
  RUN apt update &amp;&amp; apt install python3-pip  python3-dev -y
  
  ENV PYTHONUNBUFFERED 1
  ENV PYTHONDONTWRITEBYTECODE 1
  
  WORKDIR /code
  
  COPY requirements.txt /code/
  
  RUN pip3 install --upgrade pip
  
  RUN apt-get install libffi-dev
  
  RUN pip3 install cffi
  
  RUN pip3 install -r requirements.txt 
  
  COPY ./entrypoint.sh .
  RUN sed -i 's/\r$//g' /code/entrypoint.sh
  RUN chmod +x /code/entrypoint.sh
  
  COPY . /code
  RUN python3 manage.py collectstatic --no-input
  ENTRYPOINT [&quot;/code/entrypoint.sh&quot;]
  </code></pre>
  <p><strong>entrypoint.sh</strong></p>
  <pre><code>#!/bin/sh
  
  if [ &quot;$DATABASE&quot; = &quot;postgres&quot; ]
  then
      echo &quot;Waiting for postgres...&quot;
  
      while ! nc -z $SQL_HOST $SQL_PORT; do
        sleep 0.1
      done
  
      echo &quot;PostgreSQL started&quot;
  fi
  
  exec &quot;$@&quot;
  </code></pre>
  <p><strong>docker-compose.yml</strong></p>
  <pre><code>version: &quot;3.3&quot;
     
  services: 
    db_new:
      image: postgres:12.0-alpine
      container_name: db_new
      ports:
        - 5432:5432
      volumes:
        - postgres_data:/var/lib/postgresql/data/
      environment:
        - POSTGRES_USER=admin
        - POSTGRES_PASSWORD=admin
        - POSTGRES_DB=docker2
         
  
  
  
    redis:
      image: &quot;redis:alpine&quot;
    
    web:
      restart: always
      container_name: web
      build:
        context: .
        dockerfile: Dockerfile
      command: bash -c &quot;/usr/local/bin/daphne -b 0.0.0.0 -p 8000 setup.asgi:application&quot;
      volumes:
        - static_volume:/code/static/
        - media_volume:/code/media/
      ports:
        - &quot;8000:8000&quot;
      env_file:
        - ./.env
      depends_on:
        - db_new
        - redis
  
    celery:
      build: .
      command: /usr/local/bin/celery -A setup worker -l info
      depends_on:
        - db_new
        - redis
  
    celery-beat:
      build: .
      command: /usr/local/bin/celery -A setup beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler
      depends_on:
        - db_new
        - redis
  
    nginx:
      build: ./nginx
      volumes:
        - static_volume:/code/static/
        - media_volume:/code/media/
      ports:
        - 80:80
      depends_on:
        - web
  
  volumes:
    postgres_data:
    static_volume:
    media_volume:
  </code></pre>
  <p><strong>Error:</strong></p>
  <pre><code>2021-12-17 10:49:19.602 UTC [27] FATAL:  password authentication failed for user &quot;root&quot;
  db_new         | 2021-12-17 10:49:19.602 UTC [27] DETAIL:  Role &quot;root&quot; does not exist.
  db_new         |        Connection matched pg_hba.conf line 95: &quot;host all all all md5&quot;
  </code></pre>
  <p>Guys please help me on this .Thanks for ur help.</p>
  <p>When i am specifying the user as admin why its connecting as root user .What i am missing on this.</p>