Simple blog app utility to test FastAPI library and Docker functionalities
- Building blog-app image
docker build -t blogg .
- Running blog app
docker run -p 8000:8000 --network host blogg
- Launching Postgres database
docker run --name postgres-blog -e POSTGRES_PASSWORD="" \ -p 5432:5432 --network host -d postgres
- Creating database
blog
docker exec -it postgres-blog /bin/bash # On the container: psql -h localhost -p 5432 -U postgres -W # On pgsql shell create database blog; \q exit
docker-compose -f docker-compose.yaml up --build
As I’m perfecting this, the steps are quite annoying
- User docker-compose
docker-compose -f docker-compose.yaml up --build
- Above step will fail the first time.
Manually enter the
postgres-blog
container to create the databasedocker exec -it postgres-blog /bin/bash # On the container: psql -h localhost -p 5432 -U postgres -W # On pgsql shell create database blog; \q exit
- Run docker compose again. It should be ready