Download - Docker 101 for RigaDevDay 2016
![Page 1: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/1.jpg)
01
![Page 2: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/2.jpg)
About meBio: Developer, coach, speaker, author
Company: Aestas/IT (http://aestasit.com)
Email: [email protected]
Linkedin: http://www.linkedin.com/in/andreyadamovich
Lanyrd: http://lanyrd.com/profile/andreyadamovich
GitHub: https://github.com/aadamovich
SO: http://stackoverflow.com/users/162792/andreyadamovich
Twitter: @codingandrey, @aestasit
••••••••
02
![Page 3: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/3.jpg)
Let's start!03
![Page 4: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/4.jpg)
What's in this workshopStarting up Docker Machine
Docker history, components, commands
Excercises
More excercises
••••
04
![Page 5: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/5.jpg)
Practical!05
![Page 6: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/6.jpg)
PreparationTask 01a: works with surprises
Task 01b: works always, but is more geeky••
06
![Page 7: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/7.jpg)
Task 01a: Start Docker VM (toolbox)Download Docker Toolbox from:
https://www.docker.com/products/dockertoolbox.
Run full installation of all tools.
•
•
07
![Page 8: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/8.jpg)
Start Docker VM (toolbox)
08
![Page 9: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/9.jpg)
Start Docker VM (toolbox)
09
![Page 10: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/10.jpg)
Start Docker VM (toolbox)
10
![Page 11: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/11.jpg)
Task 01b: Start Docker VM (customVagrantfile)Install VirtualBox 5+
Install Vagrant 1.8+
Create new directory for your project e.g. docker‐machine
Put Vagrantfile from Gist inside that directory
(Optional) Copy trusty.box from provided USB stick
(Optional) Run vagrant box add ubuntu/trusty64 trusty.box
Run vagrant up
1.
2.
3.
4.
5.
6.
7.
11
![Page 12: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/12.jpg)
Docker facts3 years old already
29K+ stars on GitHub
100K+ dockerized applications on Docker Hub
425M+ Docker Engine downloads
180+ Docker meetup groups in 50+ countries
950+ community contributors
50K projects on GitHub using Docker
•••••••
12
![Page 13: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/13.jpg)
What is Docker?Virtualization tool like VirtualBox?
Virtual machine manager like Vagrant?
Configuration management tool like Chef or Puppet?
cgroups, libvirt, LXC?
••••
13
![Page 14: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/14.jpg)
DockerOpen source engine to commoditize LXC (containers)
Container virtualization
Build, pack, ship and run applications as containers
Build once, run in many places
Isolated and content agnostic
•••••
14
![Page 15: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/15.jpg)
Linux containersAvailable in modern kernels since 2008
Generically isolates resource usage (CPU, memory, disk, network)
Guarantee resources to application(s)
Can be adjusted on the fly
••••
15
![Page 16: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/16.jpg)
Kernel namespacesisolating views of the system
can make a process think it's the only process
builtin way to "virtualize" processes
•••
16
![Page 17: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/17.jpg)
Kernel namespacesmnt (mount points, filesystem)
pid (processes)
net (network stack)
ipc (interprocess communication)
uts (hostname)
user (UIDs)
••••••
17
![Page 18: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/18.jpg)
Inside the container (application)my code
my libraries
my package manager
my app
my data
•••••
18
![Page 19: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/19.jpg)
Outside the container (operations)logging
remote access
network configuration
monitoring
••••
19
![Page 20: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/20.jpg)
Container performanceProccesses are isolated, but run directly on the host
CPU native performance
Memory small footprint required
Netowork small overhead
••••
20
![Page 21: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/21.jpg)
Containers vs. VMs
21
![Page 22: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/22.jpg)
Containers vs. VMs
22
![Page 23: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/23.jpg)
Dockerconcepts
23
![Page 24: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/24.jpg)
Docker engineDocker is a simple client/server application
A Docker Client talks to Docker daemon, which executes the work
Docker Daemon also exposes RESTFul API, that can be used
remotely
•••
24
![Page 25: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/25.jpg)
Docker imagesReadonly templates from which containers are launched
Each image consists of series of layers using union file system
When image gets modified a new layer is created
Docker can also use additional file systems
••••
25
![Page 26: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/26.jpg)
Docker images
26
![Page 27: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/27.jpg)
Docker imagesDocker images can be shared
Standard templates for starting containers
Reproducible way to easily build trusted images
•••
27
![Page 28: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/28.jpg)
Docker containerSingle process running within environment created from Docker Image“28
![Page 29: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/29.jpg)
Docker registryA repository of Docker images
Registry can be private or public
Docker Hub is a public Docker registry
•••
29
![Page 30: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/30.jpg)
Dockerfile
30
![Page 31: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/31.jpg)
Dockercommands31
![Page 32: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/32.jpg)
docker pullPull image from remote registry (or Docker Hub) into local cache of
Docker images on current Docker Host:
docker pull busybox01.
32
![Page 33: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/33.jpg)
docker imagesList images cached on current Docker Host:
docker images01.
33
![Page 34: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/34.jpg)
docker buildBuild Docker Image from Dockerfile located in current directory:
docker build ‐t=myimage:1.0 .01.
34
![Page 35: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/35.jpg)
docker rmiRemove image from local cache:
docker rmi <image_id>01.
35
![Page 36: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/36.jpg)
docker runStart container from Docker image:
docker run busybox echo "hello world"01.
36
![Page 37: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/37.jpg)
docker psList currently running container:
docker ps01.
37
![Page 38: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/38.jpg)
docker stop|kill(Forcedly) Stop running container:
docker kill <container_id>01.
38
![Page 39: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/39.jpg)
docker rmRemove stopped container:
docker rm <container_id>01.
39
![Page 40: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/40.jpg)
Task 02 (start your first Docker containerfrom existing image)Get image from Docker Registry e.g. docker pull jenkins
List available images with docker images
Start your first container docker run jenkins
Press Ctrl+C to kill container and check that it's not running with
docker ps
Run container in detached mode by passing ‐d option.
Expose port to access container from your host using ‐p option.
••••
••
40
![Page 41: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/41.jpg)
Task 03 (build an image from existingDockerfile)Get aaconvert project from GitHub with git clone
https://github.com/mafr/docker‐aaconvert.git
From project's directory run: docker build ‐t aaconvert .
Start throwaway container to convert an image into ASCII art: docker
run ‐‐rm aaconvert
https://docs.docker.com/images/favicon.png > docker.txt
•
••
41
![Page 42: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/42.jpg)
Task 04 (build your own Docker image)Create Dockerfile to install and run PetClinic application.
Application code is here: https://github.com/springprojects/spring
petclinic.
Build Docker image with the help of docker build ‐‐
tag=petclinic:1.0 .
Verify image is listed with docker images .
••
•
•
42
![Page 43: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/43.jpg)
Task 05 (start Docker container fromyour image)Start container(s) with docker run petclinic:1.0 command.
Access container's process through its port(s).
Kill container(s) with docker kill .
Remove container(s) with docker rm .
Remove image(s) with docker rmi .
•••••
43
![Page 44: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/44.jpg)
Task 06 (use remote Docker Engine)Configure DOCKER_HOST environment variable to use
NNN.NNN.NNN.NNN:2375 (real IP is written on white board).
Build images with unique ‐‐tag option to not conflict with other
students.
Start containers on the remote host by exposing unique ports with ‐p
(available range is 80818099) and naming containers with ‐‐name .
Play with docker ps and ‐‐filter to identify and kill only your
containers.
•
•
•
•
44
![Page 45: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/45.jpg)
Conclusion45
![Page 46: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/46.jpg)
Linkshttps://www.docker.com/products/dockertoolbox
https://github.com/wsargent/dockercheatsheet
https://www.mindmeister.com/389671722/opencontainerecosystem
formerlydockerecosystem
•••
46
![Page 47: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/47.jpg)
Book: Docker up and running
47
![Page 48: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/48.jpg)
UpcomingEvents
48
![Page 49: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/49.jpg)
Meetup: Latcraft
49
![Page 50: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/50.jpg)
Conference: Baltic DevOps
50
![Page 51: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/51.jpg)
Conference: DevOps Pro
51
![Page 52: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/52.jpg)
Conference: DevTernity
52
![Page 53: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/53.jpg)
More Trainings
53
![Page 54: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/54.jpg)
Training: DevOps MasterClass / ExtremeAutomationThis 2day workshop focuses on solving challenges that organisations
face when implementing DevOps initiatives. It introduces principles of
DevOps and tools that help reach full automation of infrastructure
provisioning and software delivery. Theoretical background as well as
practical handson examples of tools like Vagrant, Docker, AWS and
others are given during this workshop.
“54
![Page 55: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/55.jpg)
Training: JVM Internals & TuningThis 2day training dives deep into the JVM internals and tool set
offered by JVM's ecosystem. It also describes possible scenarios that
may arise during production system support. Understanding of JVM
internal architecture may help developers to write code that is more
efficient; performance analysis and tuning of JVM parameters may
help operations team to quicker find and report problems.
“55
![Page 56: Docker 101 for RigaDevDay 2016](https://reader030.vdocument.in/reader030/viewer/2022021506/58ab67e21a28abbc2a8b6737/html5/thumbnails/56.jpg)
Thank you!56