r @ 1 0 7 . 1 7 0 . 2 5 3 . 2 0 3 Password o p e n w e s t 2 0 1 5 SET SAIL WITH DOCKER DOCKER FOR DEVELOPMENT ENVIRONMENTS Presented on May 8th, 2015 at by . OpenWest Conference Joshua Gardner
for Linux. ADVANTAGES: Strong Isolation Speed Repeatability: Images and Dockerfiles Composable Simulates a Production Environment FORGET “IT WORKS ON MY MACHINE.”
can be used on all recent Linux distributions, and in combination with VirtualBox on Mac OS X and Windows. Docker.com c u r l h t t p s : / / g e t . d o c k e r . c o m / | s h D O C K E R - C O M P O S E p i p 2 i n s t a l l u s e r u p g r a d e d o c k e r c o m p o s e
templates for containers. How to make images: Download from a registry From a container From a D o c k e r f i l e Containers are created with d o c k e r r u n .
provided SSH account: d o c k e r p u l l u b u n t u : 1 4 . 0 4 d o c k e r r u n u b u n t u : 1 4 . 0 4 e c h o ' h e l l o , d o c k e r ! ' This creates a container that runs the e c h o command. When the command exits the container exits but still exists. d o c k e r p s a
r r m h a p p y _ h e i s e n b e r g You can use either part of the SHA ID of the container or the randomly assigned name which has the form “adjective_scientist”.
h o n : 3 . 4 A D D . / c o d e W O R K D I R / c o d e 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 R U N p i p i n s t a l l u w s g i E X P O S E 8 0 0 0 C M D [ " u w s g i " , " h t t p " , " : 8 0 0 0 " , " w s g i f i l e " , " / c o d e / w s g i . p y " ] With Dockerfile named "Dockerfile" and in directory with files "requirements.txt" and "wsgi.py", run build: d o c k e r b u i l d t m y w s g i a p p .
i n / e n v p y t h o n 3 f r o m f l a s k i m p o r t F l a s k f r o m r e d i s i m p o r t R e d i s a p p = F l a s k ( _ _ n a m e _ _ ) r e d i s = R e d i s ( h o s t = ' r e d i s ' , p o r t = 6 3 7 9 ) @ a p p . r o u t e ( ' / ' ) d e f h e l l o ( ) : r e d i s . i n c r ( ' h i t s ' ) r e t u r n ' H e l l o W o r l d ! I h a v e b e e n s e e n { } t i m e s . \ n ' . f o r m a t ( i n t ( r e d i s . g e t ( ' h i t s ' ) ) ) i f _ _ n a m e _ _ = = " _ _ m a i n _ _ " : a p p . r u n ( h o s t = " 0 . 0 . 0 . 0 " , d e b u g = T r u e )
m a p p / D o c k e r f i l e DOCKERFILE F R O M p y t h o n : 3 . 4 A D D . / c o d e W O R K D I R / c o d e 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 E X P O S E 5 0 0 0 C M D [ " p y t h o n " , " a p p . p y " ]
e r - c o m p o s e . y m l file: v i m d o c k e r c o m p o s e . y m l DOCKER-COMPOSE.YML w e b : b u i l d : a p p / c o m m a n d : p y t h o n a p p . p y v o l u m e s : " . / a p p / : / c o d e " p o r t s : " 5 0 0 0 : 5 0 0 0 " l i n k s : r e d i s r e d i s : i m a g e : r e d i s
a g e : p o s t g r e s : l a t e s t v o l u m e s : " . : / c o d e " d s e : b u i l d : d s e / c o m m a n d : / b i n / t r u e c a s s a n d r a A : i m a g e : a c m e _ d s e v o l u m e s : " . / c a s s a n d r a A / d a t a : / v a r / l i b / c a s s a n d r a " " . / c a s s a n d r a A / l o g : / v a r / l o g / c a s s a n d r a " " . / c a s s a n d r a A / s p a r k d : / v a r / l i b / s p a r k " " . / c a s s a n d r a A / s p a r k l : / v a r / l o g / s p a r k " c o m m a n d : c a s s a n d r a p o r t s :