Docker

BWAELS.IO - @baptwaels

Thanks a lot ! :)

It was a great experience.

Thanks a lot ! :)

It was a great experience.

Thanks a lot ! :)

It was a great experience.

You can find me here : 

Thanks a lot ! :)

It was a great experience.

You can find me here : 

bwaels.io

Thanks a lot ! :)

It was a great experience.

You can find me here : 

bwaels.io

@BaptWaels

~ $ company="Decathlon"
~ $ service="Offer & Product Communication"
~ $ jobs=(dev fullstack communityAnimator)
~ $ buzzwordsAboutMyJob=(AngularJS Groovy GitAdvanced beers Bash rpm Docker Jenkins fullstack
python swimming gitHooks springMVC running)

~ $ echo "Hi ! I am" `whoami`
Hi ! I am Baptiste Waels - (ex)CIR - Master 2 - Contrat Pro

~ $ echo "I work for" $company "as a" `echo $jobs`
I work for Decathlon as a dev fullstack devops animator

~ $ echo $buzzwordsAboutMyJob
AngularJS Groovy GitAdvanced beers Bash rpm Docker Jenkins swimming gitHooks springMVC running

`whoami`

What is

What is Docker ?

Docker is an open platform for building, shipping and running distributed applications.

docker.io

What is Docker ?

$15 000 000

$1 000 000 000

Back to THE 90's

MY APP

+

A REAL Server

=

VIRTUAL MACHINEs

VIRTUAL MACHINEs

VIRTUAL MACHINEs

VIRTUAL MACHINEs

REUSABLE IMAGES

VIRTUAL MACHINEs

REUSABLE IMAGES

SNAPSHOTS

VIRTUAL MACHINEs

REUSABLE IMAGES

SNAPSHOTS

SIMPLIFY CLUSTERS CREATION

 

""too heavy""

Docker containers

Docker containers

Docker containers

VM

Docker

LXC =

OS-level virtualization for running multiple isolated Linux systems 

"LINUX CONTAINERS"

cgroups =

Linux kernel feature that limits and isolates the resource usage

(CPU, disk I/O, network, etc.)

"CONTROL GROUPS"

AUFs =

Filesystem which is based on images where every modification is a diff from the previous one (Like commits in git)

"Adv. multi layered Unification FS"

What is the aim of Docker ?

CONF@42 - Docker - MeetUp #25

http://www.dailymotion.com/video/x39cc2t

(7 Octobre 2015)

HOW TO INSTALL ?

HOW TO INSTALL ?

http://docs.docker.com/installation

HOW TO INSTALL ?

http://docs.docker.com/installation

Docker HUB

Over 1.2B Pulls

from Docker Hub

5.6M

65

240K

Pulls per Day

Pulls per Second

Repositories on

Docker Hub

Docker Search

~ $ docker search -h
Usage: docker search [OPTIONS] TERM

Search the Docker Hub for images

  --automated=false    Only show automated builds
  --no-trunc=false     Don't truncate output
  -s, --stars=0        Only displays with at least x stars

Docker Search

~ $ docker search hello-world
NAME                                    DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
hello-world                             Hello World! (an example of minimal Docker...   24        [OK]       
tutum/hello-world                       Image to test docker deployments. Has Apac...   12                   [OK]
marcells/aspnet-hello-world             ASP.NET vNext - Hello World                     1                    [OK]
vegasbrianc/docker-hello-world                                                          1                    [OK]
diegomarangoni/devops-hello-world-app   Example application for deploying using Co...   1                    [OK]
nirmata/hello-world                                                                     0                    [OK]
crccheck/hello-world                    Hello World web server in under 2.5 MB          0                    [OK]
poojathote/hello-world                  this is 3rd POC                                 0                    [OK]
adamkdean/hello-world                                                                   0                    [OK]
davelesser/hello-world                                                                  0                    [OK]
milkyway/java-hello-world               Java Hello World Test Docker Image              0                    [OK]
rcarun/hello-world                                                                      0                    [OK]
suryasumukh/hello-world                 A docker auto build test application            0                    [OK]
sixeyed/coreclr-hello-world             A simple Hello World sample, running as a ...   0                    [OK]
keithchambers/docker-hello-world                                                        0                    [OK]
fermayo/hello-world                                                                     0                    [OK]
craigbarrau/docker-java-hello-world     This is an automated build of docker java-...   0                    [OK]
svlapin/docker-hello-world              Hello world automated build                     0                    [OK]
jaimalchohan/hello-world-node-docker    A simple hello world app                        0                    [OK]

Docker pull

~ $ docker pull -h
Usage: docker pull [OPTIONS] NAME[:TAG] | [REGISTRY_HOST[:REGISTRY_PORT]/]NAME[:TAG]

Pull an image or a repository from the registry

  -a, --all-tags=false          Download all tagged images in the repository
  --disable-content-trust=true  Skip image verification

Docker pull

~ $ docker pull hello-world
latest: Pulling from hello-world

535020c3e8ad: Pull complete 
af340544ed62: Pull complete 
Digest: sha256:a68868bfe696c00866942e8f5ca39e3e31b79c1e50feaee4ce5e28df2f051d5c
Status: Downloaded newer image for hello-world:latest
~ $ 

RUN Command

~ $ docker run -h
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

Run a command in a new container

  -a, --attach=[]               Attach to STDIN, STDOUT or STDERR
  --add-host=[]                 Add a custom host-to-IP mapping (host:ip)
  --blkio-weight=0              Block IO weight (relative weight)
  -c, --cpu-shares=0            CPU shares (relative weight)
  [...]

RUN Command

~ $ docker run ubuntu:latest echo "Docker is awesome"    

Unable to find images 'ubuntu:latest' locally
latest: Pulling from ubuntu

d3a1f33e8a5a: Pull complete 
c22013c84729: Pull complete 
d74508fb6632: Pull complete 
91e54dfb1179: Pull complete 
ubuntu:latest: The image you are pulling has been verified.

Digest: sha256:73fbe2308f5f5cb6e343425831b8ab44f10bbd77070ecdfbe4081daa4dbe3ed1
Status: Downloaded newer image for ubuntu:latest

Docker is awesome
~ $ 
~ $ docker run -it ubuntu:latest /bin/bash

root@b91b6d0cf193:/# ls
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@b91b6d0cf193:/# exit
exit

~ $

RUN Command

~ $ docker run ubuntu:latest echo "Docker is awesome"    

Unable to find images 'ubuntu:latest' locally
latest: Pulling from ubuntu

d3a1f33e8a5a: Pull complete 
c22013c84729: Pull complete 
d74508fb6632: Pull complete 
91e54dfb1179: Pull complete 
ubuntu:latest: The image you are pulling has been verified.

Digest: sha256:73fbe2308f5f5cb6e343425831b8ab44f10bbd77070ecdfbe4081daa4dbe3ed1
Status: Downloaded newer image for ubuntu:latest

Docker is awesome
~ $ 

images & rmi command

~ $ docker images -h
Usage: docker images [OPTIONS] [REPOSITORY]

List images

  -a, --all=false      Show all images (default hides intermediate images)
  --digests=false      Show digests
  -f, --filter=[]      Filter output based on conditions provided
  --help=false         Print usage
  --no-trunc=false     Don't truncate output
  -q, --quiet=false    Only show numeric IDs

images & rmi command

~ $ docker images
REPOSITORY                             TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
ubuntu                                 latest              91e54dfb1179        16 minutes ago      188.4 MB
hello-world                            latest              af340544ed62        4 minutes ago       960 B

images & rmi command

~ $ docker images
REPOSITORY                             TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
ubuntu                                 latest              91e54dfb1179        16 minutes ago      188.4 MB
hello-world                            latest              af340544ed62        4 minutes ago       960 B
~ $ docker rmi -f hello-world                         
Untagged: hello-world:latest
Deleted: af340544ed62de0680f441c71fa1a80cb084678fed42bae393e543faea3a572c
Deleted: 535020c3e8add9d6bb06e5ac15a261e73d9b213d62fb2c14d752b8e189b2b912
~ $ docker images
REPOSITORY                             TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
ubuntu                                 latest              91e54dfb1179        16 minutes ago      188.4 MB

PS & RM command

~ $ docker ps -h
Usage: docker ps [OPTIONS]

List containers

  -a, --all=false       Show all containers (default shows just running)
  --before=""           Show only container created before Id or Name
  -f, --filter=[]       Filter output based on conditions provided
  -l, --latest=false    Show the latest created container, include non-running
  -n=-1                 Show n last created containers, include non-running
  --no-trunc=false      Don't truncate output
  -q, --quiet=false     Only display numeric IDs
  -s, --size=false      Display total file sizes
  --since=""            Show created since Id or Name, include non-running
  --format=[]       Pretty-print containers using a Go template

PS & RM command

~ $ docker ps
CONTAINER ID    IMAGE               COMMAND                CREATED              STATUS             PORTS      NAMES
89951e446cf0    postgres:latest     "/docker-entrypoint.   8 seconds ago        Up 7 seconds       5432/tcp   pensive        
dd5fe50ab712    ubuntu:latest       "sleep 20000000"       41 seconds ago       Up 40 seconds                 adoring      
eea75a0a071f    ubuntu:latest       "/bin/bash"            About a minute ago   Up About a minute             insane      
~ $ 

PS & RM command

~ $ docker rm -f 89951e446cf0
89951e446cf0
~ $ docker ps
CONTAINER ID    IMAGE               COMMAND                CREATED              STATUS             PORTS      NAMES
dd5fe50ab712    ubuntu:latest       "sleep 20000000"       41 seconds ago       Up 40 seconds                 adoring      
eea75a0a071f    ubuntu:latest       "/bin/bash"            About a minute ago   Up About a minute             insane      
~ $ 
~ $ docker ps
CONTAINER ID    IMAGE               COMMAND                CREATED              STATUS             PORTS      NAMES
89951e446cf0    postgres:latest     "/docker-entrypoint.   8 seconds ago        Up 7 seconds       5432/tcp   pensive        
dd5fe50ab712    ubuntu:latest       "sleep 20000000"       41 seconds ago       Up 40 seconds                 adoring      
eea75a0a071f    ubuntu:latest       "/bin/bash"            About a minute ago   Up About a minute             insane      
~ $ 

exec command

~ $ docker exec -h
Usage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...]

Run a command in a running container

  -d, --detach=false         Detached mode: run command in the background
  -i, --interactive=false    Keep STDIN open even if not attached
  -t, --tty=false            Allocate a pseudo-TTY
  -u, --user=                Username or UID (format: <name|uid>[:<group|gid>])

exec command

~ $ docker ps
CONTAINER ID    IMAGE               COMMAND                CREATED              STATUS             PORTS      NAMES
89951e446cf0    postgres:latest     "/docker-entrypoint.   8 seconds ago        Up 7 seconds       5432/tcp   pensive       
dd5fe50ab712    ubuntu:latest       "sleep 20000000"       41 seconds ago       Up 40 seconds                 adoring      
eea75a0a071f    ubuntu:latest       "/bin/bash"            About a minute ago   Up About a minute             insane      
~ $ 

exec command

~ $ docker ps
CONTAINER ID    IMAGE               COMMAND                CREATED              STATUS             PORTS      NAMES
89951e446cf0    postgres:latest     "/docker-entrypoint.   8 seconds ago        Up 7 seconds       5432/tcp   pensive       
dd5fe50ab712    ubuntu:latest       "sleep 20000000"       41 seconds ago       Up 40 seconds                 adoring      
eea75a0a071f    ubuntu:latest       "/bin/bash"            About a minute ago   Up About a minute             insane      
~ $ 
~ $ docker exec -it dd5fe50ab712 /bin/bash
root@dd5fe50ab712:/# ls     
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@dd5fe50ab712:/# exit
exit
~ $ 

Docker Volume

data volume is a specially-designated directory within one or more containers that bypasses the Union File System.

Docker Volume

~ $ ls /Users/baptou/myDirectory
file1 file2 file3
~ $ docker run -it -v /Users/baptou/myDirectory:/opt ubuntu:latest /bin/bash
root@29088b02f260:/# ls /opt
file1  file2 file3
root@29088b02f260:/# rm /opt/file2
root@29088b02f260:/# ls /opt
file1 file3
root@29088b02f260:/# exit
exit
~ $ ls /Users/baptou/myDirectory  
file1 file3
~ $ 

Docker COMMIT

~ $ docker commit -h
Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]

Create a new image from a container's changes

  -a, --author=""     Author (e.g., "John Hannibal Smith <hannibal@a-team.com>")
  -c, --change=[]     Apply specified Dockerfile instructions while committing the image
  -m, --message=""    Commit message
  -p, --pause=true    Pause container during commit

Docker COMMIT

~ $ docker run -d ubuntu /bin/bash -c "apt-get install -y hello"
009e8061df58b8b123ee
~ $ docker commit -m "My first container with a Commit" 009e8061df58b8b123ee baptou/hello
b88f9422f14dc055427d39bf6971f8415511fdaa3182a37869c14c4893664c43
~ $ docker images
REPOSITORY                             TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
baptwaels/hello                        latest              b88f9422f14d        7 seconds ago       189.3 MB
feedbackfront                          latest              34cd8b4a3d8b        4 weeks ago         163 MB
offer/feedbackfront                    latest              63a5a64ddc7a        4 weeks ago         163 MB
offer/feedback-front                   latest              63a5a64ddc7a        4 weeks ago         163 MB

~ $ docker run baptwaels/hello         
Reading package lists...
Building dependency tree...
Reading state information...
hello is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

~ $ docker run -it baptwaels/hello /bin/bash
root@df8d31633a9a:/# hello
Hello, world!
root@df8d31633a9a:/# exit
exit
~ $ 

Docker push

~ $ docker push -h
Usage: docker push NAME[:TAG]

Push an image or a repository to the registry

--disable-content-trust=true   Skip image signing

Docker push

~ $ docker push baptwaels/hello
The push refers to a repository [baptwaels/hello] (len: 1)
b88f9422f14d: Image push failed 

Please login prior to push:
Username: baptwaels
Password: 
Email: bwaels@gmail.com
WARNING: login credentials saved in /Users/baptou/.dockercfg.
Login Succeeded
The push refers to a repository [baptwaels/hello] (len: 1)
b88f9422f14d: Image already exists 
91e54dfb1179: Image successfully pushed 
d74508fb6632: Image successfully pushed 
c22013c84729: Image successfully pushed 
d3a1f33e8a5a: Image successfully pushed 
Digest: sha256:d659f9011eab6d04b3d9fd9f6324e23505bd1299c52d295c4b04ebe3e58878ce

~ $ 

Docker push

Dockerfile

 A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image.

FROM ubuntu:latest

RUN apt-get install hello -y
RUN apt-get install vim -y

Dockerfile

Dockerfile

FROM ubuntu:latest

RUN apt-get install hello -y
RUN apt-get install vim -y

Dockerfile

Dockerfile

~ $ docker build -t myubuntu .
~ $ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
myubuntu            latest              4b205af179df        5 seconds ago       188.9 MB

Shell

Conclusion

 

@BaptWaels - bwaels.io

Docker

By Baptiste WAELS

Docker

Slides from the Meetup I've organised about Docker (~70 persons) Video here : https://www.youtube.com/watch?v=0en5mwdMMf4

  • 2,221