O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

Rapid Development With Docker Compose

Slides for the "Rapid Development With Docker Compose" talk as presented at Kiwi Pycon 2017.

https://www.youtube.com/watch?v=o6SScget37w

  • Seja o primeiro a comentar

Rapid Development With Docker Compose

  1. 1. Rapid Development With Docker Compose
  2. 2. Justin Crown https://github.com/mrname/
  3. 3. https://github.com/ mrname/kiwi-pycon-2017/
  4. 4. Workflow Requirements • Portable (various operating systems) • Easy to operate • Ability to rapidly iterate code changes • Minimal setup
  5. 5. Objective • Deploy a full stack Django Rest Framework application with: • Nginx reverse proxy • PostgreSQL • Django-Q for task scheduling with redis as a backend
  6. 6. docker build
 (run commands in
 dockerfile,
 create image) Docker
 Image docker run Docker
 Container
 (instance of
 image)
  7. 7. Base Image Dockerfile
  8. 8. Do not buffer output Dockerfile
  9. 9. Copy all files from CWD of 
 host to /src of container Dockerfile
  10. 10. This is now the root of all commands Dockerfile
  11. 11. Install requirements Dockerfile
  12. 12. Expose application port in container Dockerfile
  13. 13. Docker Compose Version Nginx Service Postgres Service
  14. 14. Image Based Service Build Based Service Image Used To Create Container Directory of Dockerfile Command to run in container
  15. 15. Load Env Vars From These Files
  16. 16. When Should The Container Restart?
  17. 17. Inline Environment Variables
  18. 18. Mount “.” of the host to “/src/“ of the container
  19. 19. Wait for these containers to start before we start this one
  20. 20. Forward port 8000 of host to port 8000 of container
  21. 21. docker-compose ps List Running Containers
  22. 22. docker-compose up Bring up containers, building or pulling as necessary
  23. 23. Now we have… things!
  24. 24. docker-compose exec Execute commands on running containers
  25. 25. docker-compose run Execute a single command in a ONE OFF container
  26. 26. Magical Hostname… Thanks Docker Compose!
  27. 27. Magical Hostname… Thanks Docker Compose!
  28. 28. Tips, Tricks, Caveats Container LifeCycle docker-compose start/stop/restart Affects the EXISTING CONTAINER. NOTHING IS CHANGED
  29. 29. 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
  30. 30. 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
  31. 31. Tips, Tricks, Caveats Container LifeCycle docker-compose pull • Exactly what you expect........
  32. 32. 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
  33. 33. Tips, Tricks, Caveats Networks Source: https://docs.docker.com/compose/networking/#specify-custom-networks
  34. 34. Tips, Tricks, Caveats Scaling and Load Balancing
  35. 35. Tips, Tricks, Caveats Scaling and Load Balancing Round Robin DNS FOR FREE!
  36. 36. Tips, Tricks, Caveats Application Configuration (Environment Variables)
  37. 37. Tips, Tricks, Caveats Application Configuration (Environment Variable Files)
  38. 38. Tips, Tricks, Caveats Application Configuration (Inline Environment Variables) These variables take precedence over the env file! Provide key and value Infer value from shell
  39. 39. • 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
  40. 40. 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
  41. 41. Growing Up • Kubernetes • Docker Swarm • Apache Mesos • Amazon ECS • Packer

    Seja o primeiro a comentar

    Entre para ver os comentários

  • taichunmin

    Mar. 9, 2018
  • nwaioolwin

    Jun. 30, 2018

Slides for the "Rapid Development With Docker Compose" talk as presented at Kiwi Pycon 2017. https://www.youtube.com/watch?v=o6SScget37w

Vistos

Vistos totais

276

No Slideshare

0

De incorporações

0

Número de incorporações

0

Ações

Baixados

23

Compartilhados

0

Comentários

0

Curtir

2

×