- Dockerfiles are in sub-directory Docker
- Some commands below are based on Podman (Microsoft Windows), but they are similar to Docker commands.
- Dockerfiles are based on Debian version 12 "Bookworm" (June 2023) and Python 3.11.4: python:3.11.4-slim-bookworm.
- Note: This will copy the files of the current directory, including the currently used SQLite database. Maybe you want to clean up your code first.
- Build an image from the Dockerfile-SQLite (also copies files).
It installs requirements_dev.txt, copies files and runs migrate:
podman build --tag eventslite --file Docker/Dockerfile-SQLite ./
- Create and run a new container from the image:
podman run --name eventslite --detach --interactive --tty --publish 8000:8000 eventslite
- Import example data:
podman exec eventslite python manage.py loaddata events/fixtures/examples/0001_user.xml events/fixtures/examples/0002_person.xml events/fixtures/examples/0003_event.xml events/fixtures/examples/0004_registration.xml
- Start server in interactive bash:
podman exec --interactive --tty eventslite bash
python manage.py runserver 0.0.0.0:8000
- Stop server in interactive bash:
- Press [ctrl]+[c] and type
exit
- Press [ctrl]+[c] and type
- Stop the container:
podman stop eventslite
- Create and start containers from the Dockerfile.
It installs requirements_prod.txt, copies files and runs migrate:
podman-compose --file Docker/docker-compose.yml --project-name events up --detach
- Passwords for the database and superuser are set via environment variables in docker-compose.yml.
- To stop and remove containers, use
down
- To (re-) build services, use
build
- Docker CLI reference, Podman commands
- Docker compose CLI reference, Podman compose command
podman images --all
List all imagespodman rmi events
Remove events imagepodman rmi --all
Remove all imagespodman ps --all
List all containerspodman rm events
Remove containers eventspodman rm --all
Remove all containers- Clean up:
podman rmi events_events
podman image prune
podman volume rm events_postgres
podman volume prune
# Ensure Python output is logged to the terminal, making it possible to monitor Django logs in realtime
# https://www.nileshdalvi.com/blog/dockerize-django-app/
#
# Force the stdout and stderr streams to be unbuffered
# https://docs.python.org/3/using/cmdline.html#envvar-PYTHONUNBUFFERED
ENV PYTHONUNBUFFERED 1
- Docker Hub
- postgres Website also describes environment variables and compose usage
- postgres:16.0-bookworm