Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

Building Python Web Apps with Docker - PyTexas ...

Avatar for Mark Adams Mark Adams
September 26, 2015

Building Python Web Apps with Docker - PyTexas 2015

Slides from my PyTexas 2015 talk about building Python apps using the Docker ecosystem!

Avatar for Mark Adams

Mark Adams

September 26, 2015
Tweet

More Decks by Mark Adams

Other Decks in Programming

Transcript

  1. Building Python Web Apps with Docker Mark Adams • Bitbucket

    Developer • Atlassian • @markadams
  2. What we'll cover (hopefully) What is Docker? A Python web

    app Docker Engine Docker Hub Docker Compose Docker Machine
  3. Traditional Virtual Machines APP A APP B LIBS LIBS GUEST

    OS GUEST OS HYPERVISOR HOST OS SERVER Robust Monolithic Slow to boot Heavy
  4. Containers APP A APP B LIBS LIBS DOCKER HOST OS

    SERVER Lean Portable Lightweight Efficient Isolated
  5. Linux $ w g e t ­ q O ­

    h t t p s : / / g e t . d o c k e r . c o m / | s h Downloads a shell script to install the right package for your system
  6. Docker Engine Builds images and runs containers Dockerfile F R

    O M p y t h o n : 3 . 4 E X P O S E 8 0 0 0 W O R K D I R / u s r / s r c / a p p # I n s t a l l d e p e n d e n c i e s C O P Y r e q u i r e m e n t s . t x t r e q u i r e m e n t s . t x t R U N p i p i n s t a l l ­ r r e q u i r e m e n t s . t x t # C o p y t h e r e s t o f t h e a p p l i c a t i o n ' s c o d e C O P Y . / u s r / s r c / a p p # R u n t h e a p p C M D [ " . / r u n _ a p p . s h " ] d o c k e r b u i l d builds an image d o c k e r r u n creates a container from an image and runs it d o c k e r l o g s shows the logs from a container d o c k e r p s shows what's running
  7. Docker Hub http://hub.docker.com $ d o c k e r

    p u l l u b u n t u U s i n g d e f a u l t t a g : l a t e s t l a t e s t : P u l l i n g f r o m u b u n t u D o w n l o a d i n g 1 0 . 8 M B / 1 5 8 . 6 M B f e c 9 f e c 2 e 9 6 0 : D o w n l o a d c o m p l e t e 9 f 8 3 4 d b 6 f d 2 c : D o w n l o a d c o m p l e t e D o w n l o a d i n g 5 . 7 M B / 3 0 . 2 M B b 1 3 f b d a b 1 f 7 2 : D o w n l o a d c o m p l e t e 8 4 3 e 2 b d e d 4 9 8 : A l r e a d y e x i s t s d o c k e r p u s h pushes to the repository d o c k e r p u l l pulls an image from the repository Public or Private
  8. Docker Compose Describes the components of an application YML Config

    w e b : b u i l d : . l i n k s : ­ ' d b ' p o r t s : ­ ' 8 0 0 0 : 8 0 0 0 ' e n v i r o n m e n t : ­ ' D A T A B A S E _ H O S T = d b ' ­ ' D A T A B A S E _ N A M E = p o s t g r e s ' ­ ' D A T A B A S E _ U S E R = p o s t g r e s ' ­ ' D A T A B A S E _ P A S S W O R D = p o s t g r e s ' d b : i m a g e : p o s t g r e s : 9 . 4 d o c k e r - c o m p o s e u p starts all the containers d o c k e r - c o m p o s e b u i l d rebuilds your images d o c k e r - c o m p o s e s t o p stopps the containers
  9. Docker Machine Provisions and manages Docker hosts Works with ­

    a m a z o n e c 2 ­ a z u r e ­ d i g i t a l o c e a n ­ e x o s c a l e ­ g o o g l e ­ o p e n s t a c k ­ r a c k s p a c e ­ s o f t l a y e r ­ v i r t u a l b o x ­ v m w a r e v c l o u d a i r ­ v m w a r e v s p h e r e d o c k e r - m a c h i n e c r e a t e creates a new Docker host d o c k e r - m a c h i n e s s h connects to the host using SSH d o c k e r - m a c h i n e r m destroys the host d o c k e r - m a c h i n e e n v sets environment variables for your client to connect to the host