docker for .net developers

34
Docker for .NET Developers TASWAR BHATTI (MVP) SYSTEM ARCHITECT @TASWARBHATTI GEMALTO HTTP://TASWAR.ZEYTINSOFT.COM

Upload: taswar-bhatti-mvp

Post on 12-Apr-2017

376 views

Category:

Engineering


2 download

TRANSCRIPT

Page 1: Docker for .NET Developers

Docker for .NET DevelopersTASWAR BHATTI (MVP) SYSTEM ARCHITECT@TASWARBHATTI GEMALTOHTTP: / /TASWAR.ZEYT INSOFT.COM

Page 2: Docker for .NET Developers

Agenda What is Docker?

Images and ContainersDocker vs VMTooling around Docker

Dockerfile

Docker linking with other containers

Docker compose

Summary

Page 3: Docker for .NET Developers

History of Software Deployment

Page 4: Docker for .NET Developers

DevOps on your software

Page 5: Docker for .NET Developers
Page 6: Docker for .NET Developers
Page 7: Docker for .NET Developers

What is Docker? - Lightweight, open, secure platform

- Simplify building, shipping, running apps

- Shipping container system for code

- Runs natively on Linux or Windows Server

- Runs on Windows or Mac Development machines (with a virtual machine or Hyper-V)

- Relies on "images" and "containers“

- Great for microservices system architecture design and deploy

Page 8: Docker for .NET Developers

Docker Leading open-source containerization platform

Supported natively in Azure

Docker containers wrap up a piece of software in a complete filesystem that contains everything it needs to run: code, runtime, system tools, system libraries – anything you can install on a server. This guarantees that it will always run the same, regardless of the environment it is running in

Taswar Bhatti
Page 9: Docker for .NET Developers

Containers Lightweight alternative to virtual machines

Smaller, less expensive, faster to start up, and self-contained

Host Operating System

Hypervisor

Guest OS

Libraries

App

Guest OS

Libraries

App

Guest OS

Libraries

App

Operating System

Container Engine

Libraries

App

Libraries

App

Libraries

App

Virtual Machines

Containers

Page 10: Docker for .NET Developers
Page 11: Docker for .NET Developers

Images and Containers

Page 12: Docker for .NET Developers

Docker Image - Ubuntu, DotNet Core, Node etc

- An image is an inert, immutable, file essentially a snapshot of a container

- A read-only template composed of layered filesystems used to share common files

- Create Docker container instances

- Created by docker build command

- Stored in Docker registry (Docker Hub)

Page 13: Docker for .NET Developers

Docker Container - Container is an instance of your image but running

- Using the docker run command

- An isolated and secured shipping container

- created from an image that can be run, started, stopped, moved and deleted

Page 14: Docker for .NET Developers

Docker Architecture

Page 15: Docker for .NET Developers
Page 16: Docker for .NET Developers

Docker CLI Command-line interface for Docker, available for Linux, OS X, and Windows (available separately or as part of Docker Toolbox)

Page 17: Docker for .NET Developers

Running a Containerdocker run -i -t ubuntu /bin/bash

Docker CLI command

Run container with interactive terminal Pull "ubuntu"

image from Docker Hub or local registry

Command to execute in the container

Page 18: Docker for .NET Developers

Common Docker CLI Commandsdocker run - Use an image to run a container

docker pull - Pull an image from a registry

docker build - Build a Docker image

docker exec - Execute a command in a container

docker stop - Stop a running container

docker images - List available Docker images

docker ps - List running Docker containers

Page 19: Docker for .NET Developers

Is Docker only for Linux? - Can I run my windows app Docker?

- Is Docker supported in Visual Studio?

Page 20: Docker for .NET Developers

Azure Container Service Provides robust, ready-to-use Docker hosting environment

Uses open-source orchestration tools (DC/OS and Swarm)

Page 21: Docker for .NET Developers

Tools for Docker - Install docker from https://docs.docker.com/

Page 22: Docker for .NET Developers

Docker tools for windows - For windows 10 or windows 2016

◦ Contains Linux running under Hyper-V by default (MobyLinuxVM)◦ Can be switched to use windows containers (nanoserver, windows 2016)

Page 23: Docker for .NET Developers

Kitematic A GUI component for Docker

- Allows one to control the container (start, stop, remove, etc)

Page 24: Docker for .NET Developers

Demo of Kitematic

Page 25: Docker for .NET Developers

Dockerfile - A dockerfile is a simple text file that contains the commands a user could call to assemble an image.

Page 26: Docker for .NET Developers

Dockerfile (Sample) FROM microsoft/dotnet:latest

COPY . /app

WORKDIR /app

RUN ["dotnet", "restore"]

RUN ["dotnet", "build"]

EXPOSE 5000/tcp

ENV ASPNETCORE_URLS http://*:5000

ENTRYPOINT ["dotnet", "run"]

Page 27: Docker for .NET Developers

Dockerfile Best Practices Use .dockerignore

Avoid unnecessary installed packages

Run one process per container

Minimize the number of layers

A container can be stopped and destroyed and a new one built and put in place with an absolute minimum of set-up and configuration

Page 28: Docker for .NET Developers

Linking Docker Container Demo

Page 29: Docker for .NET Developers

Docker Compose

Page 30: Docker for .NET Developers

Docker compose Define and running multiple container applications

One can define it in one or multiple fileDocker-compose.yml (default file)Docker-compose.dev.ymlDocker-compose.prod.ymlUse –f option to provide multiple files

Page 31: Docker for .NET Developers

Docker-compose.yml version: ‘2’

services:

db:

image: mysql

volume:

- ./:/var/lib/mysql

ports:

- “3306:3306”

environment:

MYSQL_ROOT_PASSWORD: 123456

Page 32: Docker for .NET Developers

Demo VSCode and VS Docker Tool

Page 33: Docker for .NET Developers

Additional Resources Self Paced Training by Docker - https://training.docker.com/category/self-paced-online

Julien Corioland, TE France: HOL to get started with Docker containers on Windows: https://github.com/jcorioland/WindowsContainersHOL

Docker created content in partnership with Microsoft: Curated list of resources on Docker and Windows Containers - coming directly from docker: https://github.com/docker/community/blob/master/Docker-Meetup-Content/+Windows.md

Page 34: Docker for .NET Developers

Questions? Contact: [email protected]

Twitter: @taswarbhatti

Web: http://taswar.zeytinsoft.com