12
Docker Dockerize all the things!

Docker presentation

Embed Size (px)

Citation preview

DockerDockerize all the things!

What is Docker● Created by Solomon Hykes and owned by Docker Inc● Abstracts hardware and allows codebases to be shipped inside a “container”● Containers are the successor to Virtual Machines. Docker utilizes low level

kernel resources including cgroups and namespaces to be more efficient than virtual machines.

● Isolated, but native access to network, file systems, CPU, memory. Docker container PIDs start with “1”

● Uses libcontainer (replacing LXC) on Linux, Hyper-V on Windows, xhyve on OS X

The Case for Docker● Docker images describes all hardware dependencies for that codebase (e.g.

automake, libmysqlclient-dev, openssl, ruby, etc)● Aids in simple deployments. You pull down an image, and run a container. It

has no other setup.● Becoming the industry standard - used by Cisco, Google, IBM, Microsoft, Red

Hat, etc

Images versus Containers● One image can have many running containers● An image is the source for your code and its dependencies. Think of it as your

Virtual Machine image● A container is a running instance of your image. For example, Persuade is

actually 4 app servers, and a background jobs server. These are all the same image, but we have five containers with two different role configurations*

● Docker allows you to scale easily by just running more containers

*Persuade is not yet Dockerized. This is an example of how it could work.

Installing Docker● https://docs.docker.com/engine/getstarted/step_one/

docker run hello-world

● Docker checks for the image, sees it is not available locally, and fetches it● Docker then runs a container from the image● The container writes a message to your terminal, and exits

Running a Docker imagedocker run docker/whalesay cowsay boo

● docker is the shell command● run starts a container from an <image>● docker/whalesay is the image name● cowsay is a shell command INSIDE the image● boo is an argument to cowsay● (try other arguments for cowsay)

The Dockerfile● The building blocks for your application’s image.● Includes many common tasks like COPY, RUN, USER, ENV● Scripts how you prepare your application’s dependencies. If you need MySQL

drivers to talk to the database, you first need to install the developer library for your OS. This might look like:

RUN apt-get install ...

● If you need to add a user to run your application as, it might look like:

RUN adduser app

Interactive - Creating a Dockerfile● mkdir mydockerbuild● cd mydockerbuild● Create a file named “Dockerfile” and insert:

FROM docker/whalesay:latestRUN apt-get -y update && apt-get install -y fortunesCMD /usr/games/fortune -a | cowsay

● Try and build your container:

docker build -t docker-whale .

Interactive - Running Your Imagedocker run docker-whale

● This is the new image we just built● Fortunes is a shell command that returns a random fortune● The result of fortunes is set into cowsay● The docker image whale_say adds a graphic to cowsay

Getting Help● Most docker commands follow the convention:

docker <command> <args>

● You can get help by passing --help as an argument. E.g.

docker --help

docker build --help

Sharing a Docker Image● Images can be (and many are) shared via Docker Hub.● Images can be pulled similar to git repositories, or run from a local copy● Docker provides a “hub” for all images at hub.docker.com . ● You can pull any public image, and even host images if you sign up for a free

account.

Docker Usage at Influence Health● Influence Health has a private Docker Hub account where we host our

Dockerized applications.● Marketing automation, Jenkins, and Huey are all Dockerized applications● Other teams make extensive use of Docker in their microservices● We plan to utilize Docker extensively going forward as we embrace services

and make small, focused applications that are easy to deploy