Slide 1

Slide 1 text

App Container Docker Basics Eueung Mulyana http://eueung.github.io/docker-stuff/intro CodeLabs | Attribution-ShareAlike CC BY-SA 1 / 36

Slide 2

Slide 2 text

Outline VMs, Containers, Docker Getting Started - Docker Engine Custom Images Docker Compose 2 / 36

Slide 3

Slide 3 text

VMs, Containers & Docker Introduction 3 / 36

Slide 4

Slide 4 text

Virtual Machines Each virtual machine includes the application, the necessary binaries and libraries and an entire guest operating system - all of which may be tens of GBs in size. Containers (Docker) Containers include the application and all of its dependencies, but share the kernel with other containers. They run as an isolated process in userspace on the host operating system. They're also not tied to any speci c infrastructure. (Docker) Containers running on a single machine all share the same operating system kernel so they start instantly and make more e cient use of RAM. Images are constructed from layered lesystems so they can share common les, making disk usage and image downloads much more e cient. 4 / 36 Virtual Machines vs. Containers Containers have similar resource isolation and allocation bene ts as virtual machines but a di erent architectural approach allows them to be much more portable and e cient. Ref: docker.com

Slide 5

Slide 5 text

5 / 36

Slide 6

Slide 6 text

LXC LXC owes its origin to the development of cgroups and namespaces in the Linux kernel to support lightweight virtualized OS environments (containers) and some early work by Daniel Lezcano and Serge Hallyn dating from 2009 at IBM. The LXC Project provides tools to manage containers, advanced networking and storage support and a wide choice of minimal container OS templates. It is currently led by a 2 member team, Stephane Graber and Serge Hallyn from Ubuntu. The LXC project is supported by Ubuntu. Docker Docker is a project by dotCloud now Docker Inc released in March 2013, initially based on the LXC project to build single application containers. Docker has now developed their own implementation libcontainer that uses kernel namespaces and cgroups directly. 6 / 36 Containers Container (lightweight process virtualization) technology is not new, mainstream support in the vanilla kernel however is, paving the way for widespread adoption (Linux Kernel 3.8 - released in February 2013 - cf. Rami Rosen). FreeBSD has Jails, Solaris has Zones and there are other (Linux) container technologies: OpenVZ, VServer, Google Containers, LXC/LXD, Docker, etc. Ref: Flockport

Slide 7

Slide 7 text

Both LXC and Docker are userland container managers that use kernel namespaces to provide end user containers. We also now have Systemd-Nspawn that does the same thing. The only di erence is LXC containers have an an init and can thus run multiple processes and Docker containers do not have an init and can only run single processes. 7 / 36 LXC vs. Docker Ref: Flockport

Slide 8

Slide 8 text

8 / 36

Slide 9

Slide 9 text

9 / 36 Docker Docker allows you to package an application with all of its dependencies into a standardized unit for software development. Docker containers wrap up a piece of software in a complete lesystem 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. Docker containers run on any computer, on any infrastructure and in any cloud. Ref: docker.com

Slide 10

Slide 10 text

Containers isolate individual applications and use operating system resources that have been abstracted by Docker. Containers can be built by "layering", with multiple containers sharing underlying layers, decreasing resource usage. Ref: Docker Ecosystem - DO 10 / 36

Slide 11

Slide 11 text

Advantages Lightweight resource utilization: instead of virtualizing an entire operating system, containers isolate at the process level and use the host's kernel. Portability: all of the dependencies for a containerized application are bundled inside of the container, allowing it to run on any Docker host. Predictability: The host does not care about what is running inside of the container and the container does not care about which host it is running on. The interfaces are standardized and the interactions are predictable. 11 / 36 Docker Typically, when designing an application or service to use Docker, it works best to break out functionality into individual containers, a design recently known as micro-service architecture. This gives you the ability to easily scale or update components independently in the future. Having this exibility is one of the many reasons that people are interested in Docker for development and deployment. Ref: Docker Ecosystem - DO

Slide 12

Slide 12 text

Docker Engine Getting Started 12 / 36

Slide 13

Slide 13 text

Docker Engine When people say "Docker" they typically mean Docker Engine, the client-server application made up of the Docker daemon, a REST API that speci es interfaces for interacting with the daemon, and a command line interface (CLI) client that talks to the daemon (through the REST API wrapper). Docker Engine accepts docker commands from the CLI, such as d o c k e r r u n < i m a g e > , d o c k e r p s to list running containers, d o c k e r i m a g e s to list images, and so on. Engine is the core of Docker and nothing else will run without it. Ref: docker.com 13 / 36

Slide 14

Slide 14 text

Docker Architecture 14 / 36

Slide 15

Slide 15 text

Docker daemon The Docker daemon runs on a host machine. The user does not directly interact with the daemon, but instead through the Docker client. Docker client The Docker client, in the form of the docker binary, is the primary user interface to Docker. It accepts commands from the user and communicates back and forth with a Docker daemon. Ref: docker.com 15 / 36 Docker Architecture Docker uses a client-server architecture. The Docker client talks to the Docker daemon, which does the heavy lifting of building, running, and distributing your Docker containers. Both the Docker client and the daemon can run on the same system, or you can connect a Docker client to a remote Docker daemon. The Docker client and daemon communicate via sockets or through a RESTful API.

Slide 16

Slide 16 text

16 / 36

Slide 17

Slide 17 text

Let's Try It ... My Case: amd64 Machine, Ubuntu 16.04 17 / 36

Slide 18

Slide 18 text

$ c u r l - f s S 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 i n f o C o n t a i n e r s : 1 . . . I m a g e s : 1 5 S e r v e r V e r s i o n : 1 . 1 1 . 1 S t o r a g e D r i v e r : a u f s . . . L o g g i n g D r i v e r : j s o n - f i l e C g r o u p D r i v e r : c g r o u p f s P l u g i n s : . . . K e r n e l V e r s i o n : 4 . 4 . 0 - 2 1 - g e n e r i c O p e r a t i n g S y s t e m : U b u n t u 1 6 . 0 4 L T S . . . $ d o c k e r v e r s i o n C l i e n t : V e r s i o n : 1 . 1 1 . 1 A P I v e r s i o n : 1 . 2 3 G o v e r s i o n : g o 1 . 5 . 4 G i t c o m m i t : 5 6 0 4 c b e B u i l t : T u e A p r 2 6 2 3 : 4 3 : 4 9 2 0 1 6 O S / A r c h : l i n u x / a m d 6 4 S e r v e r : V e r s i o n : 1 . 1 1 . 1 A P I v e r s i o n : 1 . 2 3 G o v e r s i o n : g o 1 . 5 . 4 G i t c o m m i t : 5 6 0 4 c b e B u i l t : T u e A p r 2 6 2 3 : 4 3 : 4 9 2 0 1 6 O S / A r c h : l i n u x / a m d 6 4 First Step Ref: Quickstart, Install Docker $ d o c k e r r u n h e l l o - w o r l d H e l l o f r o m D o c k e r . T h i s m e s s a g e s h o w s t h a t y o u r i n s t a l l a t i o n a p p e a r s t o b e w o r k i n T o g e n e r a t e t h i s m e s s a g e , D o c k e r t o o k t h e f o l l o w i n g s t e p s : 1 . T h e D o c k e r c l i e n t c o n t a c t e d t h e D o c k e r d a e m o n . 2 . T h e D o c k e r d a e m o n p u l l e d t h e " h e l l o - w o r l d " i m a g e f r o m t h e 3 . T h e D o c k e r d a e m o n c r e a t e d a n e w c o n t a i n e r f r o m t h a t i m a g e e x e c u t a b l e t h a t p r o d u c e s t h e o u t p u t y o u a r e c u r r e n t l y r e a d 4 . T h e D o c k e r d a e m o n s t r e a m e d t h a t o u t p u t t o t h e D o c k e r c l i e n t o y o u r t e r m i n a l . T o t r y s o m e t h i n g m o r e a m b i t i o u s , y o u c a n r u n a n U b u n t u c o n t a i n $ d o c k e r r u n - i t u b u n t u b a s h S h a r e i m a g e s , a u t o m a t e w o r k f l o w s , a n d m o r e w i t h a f r e e D o c k e r h t t p s : / / h u b . d o c k e r . c o m F o r m o r e e x a m p l e s a n d i d e a s , v i s i t : h t t p s : / / d o c s . d o c k e r . c o m / u s e r g u i d e / 18 / 36

Slide 19

Slide 19 text

Try Some Commands $ d o c k e r i m a g e s R E P O S I T O R Y T A G S I Z E e m / n o t e b o o k v 1 8 6 4 . 9 M B u b u n t u 1 6 . 0 4 1 2 0 . 1 M B a l p i n e 3 . 3 4 . 7 9 8 M B b u s y b o x l a t e s t 1 . 1 1 3 M B f i r e c y b e r i c e / w h a l e s a y l a t e s t 4 7 . 2 5 M B h e l l o - w o r l d l a t e s t 9 6 0 B d o c k e r / w h a l e s a y l a t e s t 2 4 7 M B $ J O B = $ ( d o c k e r r u n - d u b u n t u / b i n / s h - c " w h i l e t r u e ; d o e c h o H e l l o w o r l d ; s l e e p 1 ; d o n e " $ d o c k e r s t o p $ J O B $ d o c k e r s t a r t $ J O B $ d o c k e r r e s t a r t $ J O B $ d o c k e r k i l l $ J O B $ d o c k e r s t o p $ J O B # C o n t a i n e r m u s t b e s t o p p e d t o r e m o v e i t $ d o c k e r r m $ J O B $ d o c k e r r m - f $ J O B # R u n n i n g c o n t a i n e r $ d o c k e r r u n - - r m f i r e c y b e r i c e / w h a l e s a y H e l l o D o c k e r _ _ _ _ _ _ _ _ _ _ _ _ _ _ < H e l l o D o c k e r > - - - - - - - - - - - - - - \ \ \ # # . # # # # # # = = # # # # # # # # # # = = = / " " " " " " " " " " " " " " " " " \ _ _ _ / = = = ~ ~ ~ { ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ / = = = - ~ ~ ~ \ _ _ _ _ _ _ o _ _ / \ \ _ _ / \ _ _ _ _ \ _ _ _ _ _ _ _ / $ d o c k e r p s - a C O N T A I N E R I D I M A G E C O M M A N D 2 f 6 f 3 3 7 5 3 0 d 5 h e l l o - w o r l d " / h e l l o " e 7 1 d b e d a f b 5 7 e m / n o t e b o o k : v 1 " t i n i - - j u p y t e r n o t e $ d o c k e r r m - f 2 f 6 f 2 f 6 f $ d o c k e r p s - a C O N T A I N E R I D I M A G E C O M M A N D e 7 1 d b e d a f b 5 7 e m / n o t e b o o k : v 1 " t i n i - - j u p y t e r n o t e $ d o c k e r r u n - i t - - e n t r y p o i n t / b i n / s h f i r e c y b e r i c e / w h a l e s a y 19 / 36

Slide 20

Slide 20 text

$ d o c k e r r u n - d - P - - n a m e w e b n g i n x 2 2 4 a 6 1 e a 8 4 c f b f 4 6 8 b d 0 9 0 a e b b d 0 b a 5 3 4 e 9 b 0 7 b b 8 e 7 e 0 0 6 8 b f a e c a 1 b a 7 2 f 7 5 4 b $ d o c k e r p s C O N T A I N E R I D I M A G E C O M M A N D C R E A T E D S T A T U S P O R T S 2 2 4 a 6 1 e a 8 4 c f n g i n x " n g i n x - g ' d a e m o n o f f " e 7 1 d b e d a f b 5 7 e m / n o t e b o o k : v 1 " t i n i - - j u p y t e r n o t e " $ d o c k e r p o r t w e b 4 4 3 / t c p - > 0 . 0 . 0 . 0 : 3 2 7 6 8 8 0 / t c p - > 0 . 0 . 0 . 0 : 3 2 7 6 9 $ d o c k e r s t o p w e b $ d o c k e r r m w e b nginx 20 / 36

Slide 21

Slide 21 text

Mount a Volume on the Container Ref: docker.com $ m k d i r m y s i t e & & c d m y s i t e m y s i t e $ e c h o " m y n e w s i t e " > i n d e x . h t m l m y s i t e $ d o c k e r r u n - d - P - v $ ( p w d ) : / u s r / s h a r e / n g i n x / h t m l - - n a m e m y w e b n g i n x d a 0 1 8 1 7 c 2 8 b b d b 2 f 3 b 7 1 2 7 5 b a 7 b 9 5 6 0 d a 4 e 6 5 f 8 7 1 6 3 2 9 c 1 6 7 8 7 c 8 3 1 8 1 7 6 0 5 3 4 c m y s i t e $ d o c k e r p o r t m y w e b 4 4 3 / t c p - > 0 . 0 . 0 . 0 : 3 2 7 7 0 8 0 / t c p - > 0 . 0 . 0 . 0 : 3 2 7 7 1 m y s i t e $ e c h o " t h i s i s c o o l " > c o o l . h t m l $ d o c k e r s t o p m y w e b $ d o c k e r r m m y w e b 21 / 36

Slide 22

Slide 22 text

Custom Images 22 / 36

Slide 23

Slide 23 text

Build Custom Image Ref: Build your own image $ m k d i r m y d o c k e r b u i l d & & c d m y d o c k e r b u i l d / & & t o u c h D o c k e r f i l e $ d o c k e r b u i l d - t d o c k e r - w h a l e . S e n d i n g b u i l d c o n t e x t t o D o c k e r d a e m o n 2 . 0 4 8 k B S t e p 1 : F R O M d o c k e r / w h a l e s a y : l a t e s t - - - > 6 b 3 6 2 a 9 f 7 3 e b S t e p 2 : R U N a p t - g e t - y u p d a t e & & a p t - g e t i n s t a l l - y f o r t u n e s - - - > R u n n i n g i n 7 3 7 5 f 2 7 5 9 7 d 7 . . . S t e p 3 : C M D / u s r / g a m e s / f o r t u n e - a | c o w s a y - - - > R u n n i n g i n 0 9 c 5 7 e 3 e b b 8 3 - - - > 4 2 8 c b a c e 4 3 1 0 R e m o v i n g i n t e r m e d i a t e c o n t a i n e r 0 9 c 5 7 e 3 e b b 8 3 S u c c e s s f u l l y b u i l t 4 2 8 c b a c e 4 3 1 0 Dockerfile F R O M d o c k e r / w h a l e s a y : l a t e s t R U N a p t - g e t - y u p d a t e & & a p t - g e t i n s t a l l - y f o r t u n e s C M D / u s r / g a m e s / f o r t u n e - a | c o w s a y $ d o c k e r r u n d o c k e r - w h a l e _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ / O n t h e o t h e r h a n d , l i f e c a n b e a n \ | e n d l e s s p a r a d e o f T R A N S S E X U A L Q U I L T I N G | | B E E S a b o a r d a c r u i s e s h i p t o | \ D I S N E Y W O R L D i f o n l y w e l e t i t ! ! / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ \ \ # # . # # # # # # = = # # # # # # # # = = = / " " " " " " " " " " " " " " " " _ _ _ / = = = ~ ~ ~ { ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ / = = = - ~ ~ ~ \ _ _ _ _ _ _ o _ _ / \ \ _ _ / \ _ _ _ _ \ _ _ _ _ _ _ / 23 / 36

Slide 24

Slide 24 text

Example Dockerfile docker/whalesay F R O M u b u n t u : 1 4 . 0 4 R U N a p t - g e t u p d a t e \ & & a p t - g e t i n s t a l l - y c o w s a y - - n o - i n s t a l l - r e c o m m e n d s \ & & r m - r f / v a r / l i b / a p t / l i s t s / * \ & & m v / u s r / s h a r e / c o w s a y / c o w s / d e f a u l t . c o w / u s r / s h a r e / c o w s a y / c o w s / o r i g - d e f a u l t . c o w # " c o w s a y " i n s t a l l s t o / u s r / g a m e s E N V P A T H $ P A T H : / u s r / g a m e s C O P Y d o c k e r . c o w / u s r / s h a r e / c o w s a y / c o w s / R U N l n - s v / u s r / s h a r e / c o w s a y / c o w s / d o c k e r . c o w / u s r / s h a r e / c o w s a y / c o w s / d e f a u l t . c o w C M D [ " c o w s a y " ] firecyberice/whalesay F R O M a l p i n e : 3 . 2 R U N a p k u p d a t e \ & & a p k a d d g i t p e r l \ & & c d / t m p / \ & & g i t c l o n e h t t p s : / / g i t h u b . c o m / j a s o n m 2 3 / c o w s a y . g i t \ & & c d c o w s a y & & . / i n s t a l l . s h / u s r / l o c a l \ & & c d . . \ & & r m - r f c o w s a y \ & & a p k d e l g i t E N V P A T H $ P A T H C O P Y d o c k e r . c o w / u s r / l o c a l / s h a r e / c o w s / # M o v e t h e " d e f a u l t . c o w " o u t o f t h e w a y s o w e c a n o v e r w r i t e i t R U N \ m v / u s r / l o c a l / s h a r e / c o w s / d e f a u l t . c o w / u s r / l o c a l / s h a r e / c o w s & & l n - s v / u s r / l o c a l / s h a r e / c o w s / d o c k e r . c o w / u s r / l o c a l / s h a r E N T R Y P O I N T [ " c o w s a y " ] 24 / 36

Slide 25

Slide 25 text

$ d o c k e r r u n - - n a m e m y r e d i s - i t u b u n t u : 1 6 . 0 4 b a s h r o o t @ a c 6 0 0 2 b 2 a 9 8 b : / # a p t - g e t u p d a t e r o o t @ a c 6 0 0 2 b 2 a 9 8 b : / # a p t - g e t i n s t a l l w g e t r o o t @ a c 6 0 0 2 b 2 a 9 8 b : / # a p t - g e t i n s t a l l b u i l d - e s s e n t i a l t c l 8 . 5 r o o t @ a c 6 0 0 2 b 2 a 9 8 b : / # w g e t h t t p : / / d o w n l o a d . r e d i s . i o / r e d i s - s t a b l e . t a r . g z r o o t @ a c 6 0 0 2 b 2 a 9 8 b : / # t a r x z f r e d i s - s t a b l e . t a r . g z r o o t @ a c 6 0 0 2 b 2 a 9 8 b : / # c d r e d i s - s t a b l e & & m a k e & & m a k e i n s t a l l r o o t @ a c 6 0 0 2 b 2 a 9 8 b : / # . / r e d i s - s t a b l e / u t i l s / i n s t a l l _ s e r v e r . s h . . . S e l e c t e d c o n f i g : P o r t : 6 3 7 9 C o n f i g f i l e : / e t c / r e d i s / 6 3 7 9 . c o n f L o g f i l e : / v a r / l o g / r e d i s _ 6 3 7 9 . l o g D a t a d i r : / v a r / l i b / r e d i s / 6 3 7 9 E x e c u t a b l e : / u s r / l o c a l / b i n / r e d i s - s e r v e r C l i E x e c u t a b l e : / u s r / l o c a l / b i n / r e d i s - c l i I s t h i s o k ? T h e n p r e s s E N T E R t o g o o n o r C t r l - C t o a b o r t . C o p i e d / t m p / 6 3 7 9 . c o n f = > / e t c / i n i t . d / r e d i s _ 6 3 7 9 I n s t a l l i n g s e r v i c e . . . S u c c e s s ! S t a r t i n g R e d i s s e r v e r . . . I n s t a l l a t i o n s u c c e s s f u l Manual Process test/myredis:v1 Ref: Getting Started with Docker r o o t @ a c 6 0 0 2 b 2 a 9 8 b : / r e d i s - s t a b l e # p s a x | g r e p r e d i s r o o t @ a c 6 0 0 2 b 2 a 9 8 b : / r e d i s - s t a b l e # s r c / r e d i s - c l i 1 2 7 . 0 . 0 . 1 : 6 3 7 9 > s e t f o o b a r O K 1 2 7 . 0 . 0 . 1 : 6 3 7 9 > g e t f o o " b a r " 1 2 7 . 0 . 0 . 1 : 6 3 7 9 > e x i t r o o t @ a c 6 0 0 2 b 2 a 9 8 b : / r e d i s - s t a b l e # e x i t $ d o c k e r p s - a $ d o c k e r c o m m i t - m " a d d r e d i s " - a " e m " m y r e d i s t e s t / m y r e d i s : v 1 s h a 2 5 6 : 9 b 7 5 a 9 4 f 6 7 c b 4 7 b 0 1 2 f 4 4 5 e d 6 5 f b 1 3 f c 6 7 d 0 5 a 0 0 a d 1 b b 2 6 2 d 2 0 b a 4 d $ d o c k e r i m a g e s | g r e p r e d i s t e s t / m y r e d i s v 1 9 b 7 5 a 9 4 f 6 7 c b 3 9 s e c o n d s a g o 4 0 8 . 3 M B 25 / 36

Slide 26

Slide 26 text

Dockerfile test/myredis:df $ d o c k e r b u i l d - t t e s t / m y r e d i s : d f . $ d o c k e r i m a g e s | g r e p r e d i s t e s t / m y r e d i s d f 9 a 4 5 0 a e 4 1 8 d 8 A b o u t a m i n u t e a g o 4 0 8 . 6 t e s t / m y r e d i s v 1 9 b 7 5 a 9 4 f 6 7 c b 1 3 m i n u t e s a g o 4 0 8 . 3 $ d o c k e r r u n - d - p 6 3 7 9 : 6 3 7 9 t e s t / m y r e d i s : d f 1 2 4 0 a 1 2 b 5 6 e 4 a 8 7 d f e 8 9 e 4 c a 4 4 0 0 e b 1 c a f d e 8 0 2 a c 0 1 8 7 a 5 4 7 7 6 f 9 e a 5 4 b b 7 f 7 4 f $ d o c k e r p s C O N T A I N E R I D I M A G E C O M M A N D C R E A T E D S T A T U S P O R T S 1 2 4 0 a 1 2 b 5 6 e 4 t e s t / m y r e d i s : d f " r e d i s - s e r v e r " $ s u d o a p t - g e t i n s t a l l r e d i s - t o o l s $ r e d i s - c l i 1 2 7 . 0 . 0 . 1 : 6 3 7 9 > s e t b a t m a n O K 1 2 7 . 0 . 0 . 1 : 6 3 7 9 > g e t b a t " m a n " 1 2 7 . 0 . 0 . 1 : 6 3 7 9 > q u i t F R O M u b u n t u : 1 6 . 0 4 R U N a p t - g e t u p d a t e R U N a p t - g e t i n s t a l l - y w g e t R U N a p t - g e t i n s t a l l - y b u i l d - e s s e n t i a l t c l 8 . 5 R U N w g e t h t t p : / / d o w n l o a d . r e d i s . i o / r e d i s - s t a b l e . t a r . g z R U N t a r x z f r e d i s - s t a b l e . t a r . g z R U N c d r e d i s - s t a b l e & & m a k e & & m a k e i n s t a l l R U N . / r e d i s - s t a b l e / u t i l s / i n s t a l l _ s e r v e r . s h E X P O S E 6 3 7 9 E N T R Y P O I N T [ " r e d i s - s e r v e r " ] 26 / 36

Slide 27

Slide 27 text

Docker Compose 27 / 36

Slide 28

Slide 28 text

Docker Compose Compose is a tool for de ning and running multi-container Docker applications. With Compose, you use a Compose le to con gure your application's services. Then, using a single command, you create and start all the services from your con guration. Using Compose is basically a three-step process: 1. De ne your app's environment with a Docker le so it can be reproduced anywhere. 2. De ne the services that make up your app in docker- compose.yml so they can be run together in an isolated environment. 3. Lastly, run docker-compose up and Compose will start and run your entire app. Ref: Overview of Docker Compose 28 / 36

Slide 29

Slide 29 text

$ d o c k e r - c o m p o s e v e r s i o n d o c k e r - c o m p o s e v e r s i o n 1 . 7 . 0 , b u i l d 0 d 7 b f 7 3 d o c k e r - p y v e r s i o n : 1 . 8 . 0 C P y t h o n v e r s i o n : 2 . 7 . 9 O p e n S S L v e r s i o n : O p e n S S L 1 . 0 . 1 e 1 1 F e b 2 0 1 3 $ c u r l - L h t t p s : / / g i t h u b . c o m / d o c k e r / c o m p o s e / r e l e a s e s / d o w n l o a d / $ c h m o d + x / u s r / l o c a l / b i n / d o c k e r - c o m p o s e Docker Compose Getting Started 29 / 36

Slide 30

Slide 30 text

Getting Started Step #1 app.py requirements.txt f l a s k r e d i s Ref: Getting Started 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 % s t i m e s . ' % r e d i s . g 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 ) 30 / 36

Slide 31

Slide 31 text

Dockerfile F R O M p y t h o n : 2 . 7 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 C M D p y t h o n a p p . p y $ d o c k e r b u i l d - t w e b . $ d o c k e r i m a g e s | g r e p w e b w e b l a t e s t d 6 f 2 5 a 9 b f 6 3 2 2 m i n u t e s a g o 6 6 7 . 7 M B Getting Started Step #2 31 / 36

Slide 32

Slide 32 text

Getting Started Step #3 docker-compose.yml v e r s i o n : ' 2 ' s e r v i c e s : w e b : b u i l d : . p o r t s : - " 5 0 0 0 : 5 0 0 0 " v o l u m e s : - . : / c o d e d e p e n d s _ o n : - r e d i s r e d i s : i m a g e : r e d i s 32 / 36

Slide 33

Slide 33 text

Getting Started Step #4 $ d o c k e r - c o m p o s e u p C r e a t i n g n e t w o r k " c o m p o s e t e s t _ d e f a u l t " w i t h t h e d e f a u l t d r i v e r B u i l d i n g w e b . . . $ d o c k e r - c o m p o s e u p - d 33 / 36

Slide 34

Slide 34 text

Refs 34 / 36

Slide 35

Slide 35 text

Refs 1. Docker Introduction 2. Docker - Documentation 3. Docker Ecosystem - Digital Ocean 4. LXC vs. Docker - Flockport 5. CLIs Reference docker ps 6. Open Container Initiative 7. Getting Started with Docker 8. Docker Compose - Getting Started 35 / 36

Slide 36

Slide 36 text

END Eueung Mulyana http://eueung.github.io/docker-stuff/intro CodeLabs | Attribution-ShareAlike CC BY-SA 36 / 36