containerizing a django app built with the pydanny cookiecutter for deployment to an EC2 instance. the docker_compose.yml is pretty straigtforward:
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
....
nothing exotic in the dockefile; just pointers to backup and restore scripts and commands to make them executable:
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
I've tried several variations on my db env variables, the latest of which looks like:
# PostgreSQL
POSTGRES_PASSWORD='postgrespass'
POSTGRES_USER='postgres'
the container builds and initializes without problem on:
docker-compose build postgres
docker-compose up -d
but when I try to make and migrate initial data to the db with:
docker-compose run django /usr/local/bin/python manage.py makemigrations
the db is unresponsive – "Postgres is unavailable - sleeping" and docker logs db returns:
DETAIL: Connection matched pg_hba.conf line 95: "host all all all md5"
FATAL: password authentication failed for user "'postgres'"
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.