title: can't authenticate user in postgres docker container
body: <p>containerizing a django app built with the pydanny cookiecutter for deployment to an EC2 instance. the docker_compose.yml is pretty straigtforward:</p>
  
  <pre><code>version: '2'
  
  volumes:
    postgres_data: {}
    postgres_backup: {}
  
  services:
    postgres:
      build: ./compose/postgres
      volumes:
        - postgres_data:/var/lib/postgresql/data
        - postgres_backup:/backups
      env_file: .env
  
    ....
  </code></pre>
  
  <p>nothing exotic in the dockefile; just pointers to backup and restore scripts and commands to make them executable:</p>
  
  <pre><code>FROM postgres:9.4
  
  # add backup scripts
  ADD backup.sh /usr/local/bin/backup
  ADD restore.sh /usr/local/bin/restore
  ADD list-backups.sh /usr/local/bin/list-backups
  
  # make them executable
  RUN chmod +x /usr/local/bin/restore
  RUN chmod +x /usr/local/bin/list-backups
  RUN chmod +x /usr/local/bin/backup
  </code></pre>
  
  <p>I've tried several variations on my db env variables, the latest of which looks like:</p>
  
  <pre><code># PostgreSQL
  POSTGRES_PASSWORD='postgrespass'
  POSTGRES_USER='postgres'
  </code></pre>
  
  <p>the container builds and initializes without problem on:</p>
  
  <pre><code>docker-compose build postgres
  docker-compose up -d
  </code></pre>
  
  <p>but when I try to make and migrate initial data to the db with:</p>
  
  <pre><code>docker-compose run django /usr/local/bin/python manage.py makemigrations
  </code></pre>
  
  <p>the db is unresponsive – "Postgres is unavailable - sleeping" and docker logs db returns:</p>
  
  <pre><code>DETAIL:  Connection matched pg_hba.conf line 95: "host all all all md5"
  FATAL:  password authentication failed for user "'postgres'"
  </code></pre>
  
  <p>obviously I have some permission issues, but I'm not quite sure how to address them. My containers are running on an Ubuntu 16.04 AMI.</p>