- Stop any serices on host machine that use ports 80 or 5432 (such as apache2, postgresql) e.g.
service postgresql stop
- Run
docker-compose up -d --build
- Create the database schema using the provided script
docker-compose exec web python create_db.py
- Inspect the DB server to verify that tables have been created successfully
docker-compose exec db psql -U postgres --dbname=site_db
- Verify that the volume has been created
docker volume inspect flask-template_db_data
- For use in production, set environment variables in
env.prod
and then set that file as theenv_file
for the web and db containers indocker-compose.yml
- When shutting down containers, is '-v' flag to erase db volume if required (
docker-compose down -v
)
Finally, set the Nginx image to a specific verison in the nginx docker file to avoid upsteam changes breaking the build.