Upload
ido-flatow
View
77
Download
5
Embed Size (px)
Citation preview
From VMs to Containers: Introducing Docker
Containers for Linux and Windows Server
Ido FlatowSenior Architect, Sela Group
Microsoft MVP & RDLevel: Intermediate
The Problem• Shipping code to server
The Matrix From Hell
The Solution
Docker Containers are NOT VMs• Easy connection to make• Fundamentally different architectures• Fundamentally different benefits
VMs
Containers
Different, Not Mutually Exclusive
Build, Ship, Run, Any App Anywhere
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
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
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"]
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
BASIC WEB APPDEMO
OK, LET’S TALK ABOUT WINDOWS CONTAINERS
What About Windows Containers?
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
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" ]
WINDOWS AND DOCKERDEMO
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
Full CI/CD with Docker
DOCKER HUB WITH GITHUB
DEMO
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
Container Layers
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
DATA PERSISTENCYDEMO
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
AZURE CONTAINER SERVICES
DEMO
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
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