Top Banner
Docker 101 Intro to Docker Presented by: Adrian Otto Prepared for: Austin Tech Talk Date: May 28, 2015
20
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Docker 101 2015-05-28

Docker 101

Intro to Docker

Presented by: Adrian Otto Prepared for: Austin Tech Talk Date: May 28, 2015

Page 2: Docker 101 2015-05-28

Adrian Otto

• Principal Architect, Rackspace • OpenStack Magnum PTL • Solum PTL

2

Page 3: Docker 101 2015-05-28

3

Page 4: Docker 101 2015-05-28

What is it?

• Docker Engine – CLI – Docker Daemon – Docker Registry

• Docker Hub – Cloud service

• Share Applications • Automate workflows • Assemble apps from components

4

Page 5: Docker 101 2015-05-28

5

Page 6: Docker 101 2015-05-28

Container

• Combines several things – Linux Cgroups – Kernel Namespaces – Docker Image – Has a lifecycle

6

Page 7: Docker 101 2015-05-28

Linux Cgroups

• Kernel Feature • Groups of processes • Control resource allocations

– CPU – Memory – Disk – I/O

• May be nested

7

Page 8: Docker 101 2015-05-28

Linux Kernel Namespaces

• Kernel Feature • Restrict your view of the system

– Mounts (CLONE_NEWNS) – UTS (CLONE_NEWUTS)

• uname() output – IPC (CLONE_NEWIPC) – PID (CLONE_NEWPID) – Networks (CLONE_NEWNET) – User (CLONE_NEWUSER)

• Not supported in Docker yet • Has privileged/unprivileged modes today

• May be nested

8

Page 9: Docker 101 2015-05-28

Docker Image

9

• NOT A FILESYSTEM • NOT A VHD • Basically a tar file • Has a hierarchy

• Arbitrary depth • Fits into the Docker Registry

Page 10: Docker 101 2015-05-28

Docker Registry

10

• Git Repo Semantics • Pull • Push • Commit • Hierarchy

Page 11: Docker 101 2015-05-28

Container

• Combines several things – Linux Cgroups – Kernel Namespaces – Docker Image – Has a lifecycle

11

Page 12: Docker 101 2015-05-28

Dockerfile

• Like a Makefile (shell script with keywords) • Extends from a Base Image • Results in a new Docker Image • Imperative, not Declarative

12

Page 13: Docker 101 2015-05-28

Dockerfile Example

FROM centos MAINTAINER [email protected] RUN yum -y install openssh-server EXPOSE 22 ADD start.sh /start.sh CMD /start.sh

13

Page 14: Docker 101 2015-05-28

Dockerfile Example

FROM adrian_server_with_ssh MAINTAINER [email protected] RUN yum -y install httpd EXPOSE 22 80 ADD start.sh /start.sh CMD /start.sh

14

Page 15: Docker 101 2015-05-28

• The Life of a Container – Conception

• BUILD an Image from a Dockerfile – Birth

• RUN (create+start) a container – Reproduction

• COMMIT (persist) a container to a new image • RUN a new container from an image

– Sleep • KILL a running container

– Wake • START a stopped container

– Death • RM (delete) a stopped container

• Extinction – RMI a container image (delete image)

Docker Container Lifecycle

15

Page 16: Docker 101 2015-05-28

Docker CLI Commands (v1.1.2)

attach Attach to a running container build Build an image from a Dockerfile commit Create new image from container's changes

cp Copy files from containers fs to host diff Inspect changes on a container's fs events Get real time events from the server export Stream contents of container as tar history Show the history of an image images List images import Create new fs image from a tarball info Display system-wide information inspect Return low-level info on a container kill Kill a running container load Load an image from a tar archive login Login to the docker registry server logs Fetch the logs of a container port Lookup public-facing port

pause Pause all processes within a containerps List containerspull Pull image or repo from docker registry push Push image or repo to docker registryrestart Restart a running containerrm Remove one or more containersrmi Remove one or more imagesrun Run a command in a new containersave Save an image to a tar archivesearch Search for an image in the docker indexstart Start a stopped containerstop Stop a running containertag Tag an image into a repositorytop Lookup running processes of a containerunpause Unpause a paused containerversion Show the docker version informationwait Block and print exit code upon cont exit

16

Page 17: Docker 101 2015-05-28

17

Questions Before Demo?

Page 18: Docker 101 2015-05-28

18

Demo

Page 19: Docker 101 2015-05-28

Demo

• Build an Image from a Dockerfile • Manually tweak an image, commit, and start a new container • Install patches in a container, and tag it as :latest • Show different distros running on the same kernel • Run a container using a different CMD than the built-in one

19

Page 20: Docker 101 2015-05-28

20