Post on 21-Feb-2017
01
About meBio: Developer, coach, speaker, author
Company: Aestas/IT (http://aestasit.com)
Email: andrey@aestasit.com
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
Let's start!03
What's in this workshopStarting up Docker Machine
Docker history, components, commands
Excercises
More excercises
••••
04
Practical!05
PreparationTask 01a: works with surprises
Task 01b: works always, but is more geeky••
06
Task 01a: Start Docker VM (toolbox)Download Docker Toolbox from:
https://www.docker.com/products/dockertoolbox.
Run full installation of all tools.
•
•
07
Start Docker VM (toolbox)
08
Start Docker VM (toolbox)
09
Start Docker VM (toolbox)
10
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
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
What is Docker?Virtualization tool like VirtualBox?
Virtual machine manager like Vagrant?
Configuration management tool like Chef or Puppet?
cgroups, libvirt, LXC?
••••
13
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
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
Kernel namespacesisolating views of the system
can make a process think it's the only process
builtin way to "virtualize" processes
•••
16
Kernel namespacesmnt (mount points, filesystem)
pid (processes)
net (network stack)
ipc (interprocess communication)
uts (hostname)
user (UIDs)
••••••
17
Inside the container (application)my code
my libraries
my package manager
my app
my data
•••••
18
Outside the container (operations)logging
remote access
network configuration
monitoring
••••
19
Container performanceProccesses are isolated, but run directly on the host
CPU native performance
Memory small footprint required
Netowork small overhead
••••
20
Containers vs. VMs
21
Containers vs. VMs
22
Dockerconcepts
23
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
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
Docker images
26
Docker imagesDocker images can be shared
Standard templates for starting containers
Reproducible way to easily build trusted images
•••
27
Docker containerSingle process running within environment created from Docker Image“28
Docker registryA repository of Docker images
Registry can be private or public
Docker Hub is a public Docker registry
•••
29
Dockerfile
30
Dockercommands31
docker pullPull image from remote registry (or Docker Hub) into local cache of
Docker images on current Docker Host:
docker pull busybox01.
32
docker imagesList images cached on current Docker Host:
docker images01.
33
docker buildBuild Docker Image from Dockerfile located in current directory:
docker build ‐t=myimage:1.0 .01.
34
docker rmiRemove image from local cache:
docker rmi <image_id>01.
35
docker runStart container from Docker image:
docker run busybox echo "hello world"01.
36
docker psList currently running container:
docker ps01.
37
docker stop|kill(Forcedly) Stop running container:
docker kill <container_id>01.
38
docker rmRemove stopped container:
docker rm <container_id>01.
39
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
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
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
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
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
Conclusion45
Linkshttps://www.docker.com/products/dockertoolbox
https://github.com/wsargent/dockercheatsheet
https://www.mindmeister.com/389671722/opencontainerecosystem
formerlydockerecosystem
•••
46
Book: Docker up and running
47
UpcomingEvents
48
Meetup: Latcraft
49
Conference: Baltic DevOps
50
Conference: DevOps Pro
51
Conference: DevTernity
52
More Trainings
53
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
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
Thank you!56