6. Objective
• Deploy a full stack Django Rest Framework
application with:
• Nginx reverse proxy
• PostgreSQL
• Django-Q for task scheduling with redis as a
backend
7.
8.
9. docker build
(run commands in
dockerfile,
create image)
Docker
Image
docker run
Docker
Container
(instance of
image)
36. Tips, Tricks, Caveats
Container LifeCycle
docker-compose start/stop/restart
Affects the EXISTING CONTAINER. NOTHING IS
CHANGED
37. Tips, Tricks, Caveats
Container LifeCycle
docker-compose up
• Recreates container if something has changed
• Avoid recreating dependent services with --no-deps
• Force build with --build
• Force recreate with --force-recreate
38. Tips, Tricks, Caveats
Container LifeCycle
docker-compose build
• Rebuilds the image, using cached layers if available. Force a completely fresh
build with --no-cache
• DOES NOT pull your base image if it exists. Force pull base with --pull
40. Tips, Tricks, Caveats
Multiple Services With Same Built Image
Build + Image means that the built image
will be tagged with the value of
the “image” argument
46. Tips, Tricks, Caveats
Application Configuration (Inline Environment Variables)
These variables take precedence over the env file!
Provide key and value
Infer value from shell
47.
48. • Remove volumes that do not require
persistence (i.e. - code)
• Use networks
• Remove extraneous port bindings
• Use prod environment variables
• Use prod WSGI server
• Use built image instead of building on host
49. Release Overview
• docker-compose build (or pull)
• docker-compose scale (updated service only)
• find old container (docker ps)
• stop old container
• remove old container
• docker-compose scale back down