Try Docker for yourself by checking out this repository!
- Download Docker
- Download Docker Compose (If not on a Mac)
- Fork this repo into your own GitHub space
- Clone this repo onto your own machine
docker-compose up
Notice how two services are created: db_1
and web_1
. See that migrations run and the server starts.
In a new tab, run:
docker-compose run web --manage.py createsuperuser
Log into the admin at http://localhost:8000/admin/
and add some content.
Visit http://localhost:8000/spells/
to see a list of your data, and http://localhost:8000/spells/{pk}/
to see a detail view of your data.
Add new features to the Spell
model, or add a new model or app.
Run
docker-compose run --rm web ./manage.py makemigrations
And then run
docker-compose run --rm web ./manage.py migrate
Hop into the shell with
docker-compose run --rm web ./manage.py shell
And experiment with poking around by importing a model and running queries on it.
Update your requirements file with something like requests
or another library you love. Stop Docker, then restart with:
docker-compose up --build
docker images
docker container ls
or
docker ps
docker-compose down
- Build your image from scratch and give it a name
- "Exec" into the Docker container with
docker exec --it
- Stop and restart just the
web
container - Add a new service to
docker-compose.yml
; maybe Redis? - Add a data volume so your data persists between coding sessions
- Add tests and run them using
docker-compose run
commands
- An Intro to Docker for Djangonauts
- Docker: Useful Command Line Stuff
- Docker tutorial
- Docker Compose tutorial
- Compose and Django tutorial
- Best Practices for Writing Dockerfiles
- 10 Things to Avoid in Docker Containers
- Video: 5 Things About Docker
- Docker CheatSheet
- Dockerizing Django, UWISGI, and Postgres the Serious Way
- Managing Sensitive Data with Docker Secrets
This repo uses the Git Commit Message StyleGuide.