From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

29
From VMs to Containers: Introducing Docker Containers for Linux and Windows Server Ido Flatow Senior Architect, Sela Group Microsoft MVP & RD Level: Intermediate

Transcript of From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

Page 1: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

From VMs to Containers: Introducing Docker

Containers for Linux and Windows Server

Ido FlatowSenior Architect, Sela Group

Microsoft MVP & RDLevel: Intermediate

Page 2: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

The Problem• Shipping code to server

Page 3: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

The Matrix From Hell

Page 4: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

The Solution

Page 5: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

Docker Containers are NOT VMs• Easy connection to make• Fundamentally different architectures• Fundamentally different benefits

Page 6: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

VMs

Page 7: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

Containers

Page 8: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

Different, Not Mutually Exclusive

Page 9: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

Build, Ship, Run, Any App Anywhere

Page 10: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

Docker Concepts - Image• What is a container image?

– Analogous to an Exported Virtual Machine’s VHD and Config files– Templates for containers– Can depend on other images– Created by running a container and

capturing changesImage

MetadataName,

Creation Data,Command To Execute,

Dependences

Contents

Files Folders

ASP.NET Core Web Server

Page 11: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

Docker Concepts - Registry• https://hub.docker.com • Official Docker images from known vendors • Share and download Docker containers

from anywhere around the globe• Or… create your own trusted Docker

registry for your images

Page 12: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

Docker Concepts – Dockerfile• Definition of a containerFROM ubuntu:14.04RUN \ apt-get update && \ apt-get -y install apache2

COPY index.html /var/www/html/index.html

EXPOSE 80

CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]

Page 13: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

Basic Docker Commands$ docker pull # Download an image from a registry$ docker images # List all images on a Docker host$ docker build # Build an image from a Dockerfile $ docker run # Run an image $ docker commit # Create an image from a container$ docker ps # List all running and stopped instances $ docker stop # Stop a running instances $ docker rm # Remove an instance $ docker rmi # Remove an image

Page 14: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

BASIC WEB APPDEMO

Page 15: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

OK, LET’S TALK ABOUT WINDOWS CONTAINERS

What About Windows Containers?

Page 16: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

Windows Containers vs. Hyper V Containers• Windows containers

– Native Windows containers

– Powered by Docker Engine

• Hyper V containers – Windows containers +

kernel isolationInfrastracture

Windows Server 2016

Docker Engine

Bins/Libs

App Bins/Libs

App

WS KernelBins/Libs

App

Windows containers

Hyper V containers

Page 17: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

Dockerfile for Windows FROM windowsservercore

# Uses dism.exe to install the IIS roleRUN dism.exe /online /enable-feature /all /featurename:iis-webserver /NoRestart

# Creates an html file and add content to this fileRUN echo "Hello World - Dockerfile" > c:\inetpub\wwwroot\index.html

# Open cmd when the container runs from the new imageCMD [ "cmd" ]

Page 18: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

WINDOWS AND DOCKERDEMO

Page 19: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

Docker, From Dev to Production• Dev

– The developer knows best what his server needs– No more “But It works my laptop” in a middle of a major deployment

• Test– Spin a full testing environment on any server in just a few clicks

• Ops– Ops don’t need to deal with the internal server configuration– Free to manage the cluster’s health and scaling

• Production– Manage your production in the most flexible way – Scale in milliseconds– Work in sync on multiple clouds

Page 20: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

Full CI/CD with Docker

Page 21: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

DOCKER HUB WITH GITHUB

DEMO

Page 22: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

Docker File System• Logical file system by grouping FS primitives into

branches (directories, file systems, snapshots)• Each branch represents a layer in a Docker image• Images can be constructed / deconstructed as

needed (vs. a huge monolithic image in VMs)• When a container is started, a writeable layer is

added to the “top” of the file system

Page 23: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

Container Layers

Page 24: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

Docker Concepts - Volume• Volumes provide data persistency• Map a volume to a directory in the container• Volumes persist after the container is deleted• Can be created in a Dockerfile, or via CLI• Can map to an existing directory on the host• Use volumes to share data between containers

Page 25: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

DATA PERSISTENCYDEMO

Page 26: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

Container Mgmt. With Mesos• Apache Mesos: cluster manager for running

applications on a scalable cluster of servers• Marathon: task runner framework for Mesos

that is designed to launch long-running applications

• Makes it easier to deploy and manage applications in large-scale clustered environments:• High-Availability • Node Constraints• Application Health Checks• API & Service Discovery

Page 27: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

AZURE CONTAINER SERVICES

DEMO

Page 28: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

Getting Your Feet Wet• Stroll on the beach

– Setup your preferred Docker environment– Fire up some prebuilt images (nginx, hello-world)

• Take a swim– Pick a well documented solution, such as Wordpress– Build it for yourself (maybe you have a flower shop?)

• Dive in– Dockerize an existing project– Build your own Dockerfiles– Experiment with Docker Compose and Docker clusters

Page 29: From VMs to Containers: Introducing Docker Containers for Linux and Windows Server

Resources• Know your Docker

– http://training.docker.com – http://docs.docker.com/userguide

• Docker on Windows Server 2016– https://blog.docker.com/2016/09/dockerforws2016/

• Docker on Azure (IaaS and PaaS)– https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-lin

ux-containers/– https://azure.microsoft.com/en-us/services/container-service/

• My Info– @IdoFlatow // [email protected] // http://www.idoflatow.net/downloads