docker 101 for rigadevday 2016

56
01

Upload: aestas-it

Post on 21-Feb-2017

850 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Docker 101 for RigaDevDay 2016

01

Page 2: Docker 101 for RigaDevDay 2016

About meBio: Developer, coach, speaker, author

Company: Aestas/IT (http://aestasit.com)

E­mail: [email protected]

Linkedin: http://www.linkedin.com/in/andreyadamovich

Lanyrd: http://lanyrd.com/profile/andrey­adamovich

GitHub: https://github.com/aadamovich

SO: http://stackoverflow.com/users/162792/andrey­adamovich

Twitter: @codingandrey, @aestasit

••••••••

02

Page 3: Docker 101 for RigaDevDay 2016

Let's start!03

Page 4: Docker 101 for RigaDevDay 2016

What's in this workshopStarting up Docker Machine

Docker history, components, commands

Excercises

More excercises

••••

04

Page 5: Docker 101 for RigaDevDay 2016

Practical!05

Page 6: Docker 101 for RigaDevDay 2016

PreparationTask 01a: works with surprises

Task 01b: works always, but is more geeky••

06

Page 7: Docker 101 for RigaDevDay 2016

Task 01a: Start Docker VM (toolbox)Download Docker Toolbox from:

https://www.docker.com/products/docker­toolbox.

Run full installation of all tools.

07

Page 8: Docker 101 for RigaDevDay 2016

Start Docker VM (toolbox)

08

Page 9: Docker 101 for RigaDevDay 2016

Start Docker VM (toolbox)

09

Page 10: Docker 101 for RigaDevDay 2016

Start Docker VM (toolbox)

10

Page 11: Docker 101 for RigaDevDay 2016

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

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

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

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

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

Kernel namespacesisolating views of the system

can make a process think it's the only process

built­in way to "virtualize" processes

•••

16

Page 17: Docker 101 for RigaDevDay 2016

Kernel namespacesmnt (mount points, filesystem)

pid (processes)

net (network stack)

ipc (inter­process communication)

uts (hostname)

user (UIDs)

••••••

17

Page 18: Docker 101 for RigaDevDay 2016

Inside the container (application)my code

my libraries

my package manager

my app

my data

•••••

18

Page 19: Docker 101 for RigaDevDay 2016

Outside the container (operations)logging

remote access

network configuration

monitoring

••••

19

Page 20: Docker 101 for RigaDevDay 2016

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

Containers vs. VMs

21

Page 22: Docker 101 for RigaDevDay 2016

Containers vs. VMs

22

Page 23: Docker 101 for RigaDevDay 2016

Dockerconcepts

23

Page 24: Docker 101 for RigaDevDay 2016

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

Docker imagesRead­only 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

Docker images

26

Page 27: Docker 101 for RigaDevDay 2016

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

Docker containerSingle process running within environment created from Docker Image“28

Page 29: Docker 101 for RigaDevDay 2016

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

Dockerfile

30

Page 31: Docker 101 for RigaDevDay 2016

Dockercommands31

Page 32: Docker 101 for RigaDevDay 2016

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

docker imagesList images cached on current Docker Host:

docker images01.

33

Page 34: Docker 101 for RigaDevDay 2016

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

docker rmiRemove image from local cache:

docker rmi <image_id>01.

35

Page 36: Docker 101 for RigaDevDay 2016

docker runStart container from Docker image:

docker run busybox echo "hello world"01.

36

Page 37: Docker 101 for RigaDevDay 2016

docker psList currently running container:

docker ps01.

37

Page 38: Docker 101 for RigaDevDay 2016

docker stop|kill(Forcedly) Stop running container:

docker kill <container_id>01.

38

Page 39: Docker 101 for RigaDevDay 2016

docker rmRemove stopped container:

docker rm <container_id>01.

39

Page 40: Docker 101 for RigaDevDay 2016

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

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 throw­away 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

Task 04 (build your own Docker image)Create Dockerfile to install and run PetClinic application.

Application code is here: https://github.com/spring­projects/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

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

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 8081­8099) 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

Conclusion45

Page 46: Docker 101 for RigaDevDay 2016

Linkshttps://www.docker.com/products/docker­toolbox

https://github.com/wsargent/docker­cheat­sheet

https://www.mindmeister.com/389671722/open­container­ecosystem­

formerly­docker­ecosystem

•••

46

Page 47: Docker 101 for RigaDevDay 2016

Book: Docker up and running

47

Page 48: Docker 101 for RigaDevDay 2016

UpcomingEvents

48

Page 49: Docker 101 for RigaDevDay 2016

Meetup: Latcraft

49

Page 50: Docker 101 for RigaDevDay 2016

Conference: Baltic DevOps

50

Page 51: Docker 101 for RigaDevDay 2016

Conference: DevOps Pro

51

Page 52: Docker 101 for RigaDevDay 2016

Conference: DevTernity

52

Page 53: Docker 101 for RigaDevDay 2016

More Trainings

53

Page 54: Docker 101 for RigaDevDay 2016

Training: DevOps MasterClass / ExtremeAutomationThis 2­day 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 hands­on examples of tools like Vagrant, Docker, AWS and

others are given during this workshop.

“54

Page 55: Docker 101 for RigaDevDay 2016

Training: JVM Internals & TuningThis 2­day training dives deep into the JVM internals and tool set

offered by JVM's eco­system. 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

Thank you!56