Fekete György (f@pulilab.com)
Senior Full-Stack Developer
pulilab.com
https://github.com/pulilab/dockerizing-django
http://slides.com/gyorgyfekete/dockerify-django (this)
Docker containers wrap up a piece of software in a complete filesystem that contains everything it needs to run: code, runtime, system tools, system libraries – anything you can install on a server. This guarantees that it will always run the same, regardless of the environment it is running in.
VirtualMachine
Container
> docker-machine create -d virtualbox dev
Creating a new docker machine (Mac OS X)
> eval "$(docker-machine env dev)"
Activate the new docker machine
> docker-machine ls
List machines
> docker-compose build
> docker-compose up -d
Build images
> docker-compose run web python manage.py migrate
Migrate Django
> docker-compose logs
Check logs
> psql -h 192.168.99.100 -p 5432 -U postgres --password
Connect to DB
> docker-machine create -d digitalocean --digitalocean-access-token=YOUR_TOKEN --digitalocean-region=ams3 production
PRODUCTION: create prod machine
> eval "$(docker-machine env production)"
PRODUCTION: activate prod machine
> docker-compose build
> docker-compose -f production.yml up -d
PRODUCTION: build prod image
> docker ps
> docker exec dockerizingdjango_web_1 python manage.py migrate
PRODUCTION: run migrations on prod