aspnet core developer workflow with docker

28
Developer Workflow using Docker (with ASP.NET Core) Wyn Van Devanter @wynv w [email protected]

Upload: wyn-devanter

Post on 13-Jan-2017

310 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Aspnet core developer workflow with docker

Developer Workflow using Docker (with

ASP.NET Core)Wyn Van Devanter

@[email protected]

Page 2: Aspnet core developer workflow with docker

Agenda• What is Docker? • Benefits & Attributes • Docker basics • Demo • Build a container for development (in ASP.NET Core)• Run & change an app• Run multiple containers (app & database) with Docker Compose

Page 3: Aspnet core developer workflow with docker

What is Docker?Docker containers wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries – anything that can be installed on a server.

Page 4: Aspnet core developer workflow with docker

What is Docker?• A VM gives you a OS in a window• A container gives you a file system via background process(es)

Page 5: Aspnet core developer workflow with docker

VMs vs Containers• VMs are good at managing units of hardware resources • Containers are good at managing units of software

Page 6: Aspnet core developer workflow with docker

ContainersVirtual Machines

Page 7: Aspnet core developer workflow with docker

Benefits of containers• Consistent • Very portable • Fast to spin up • Smaller footprint • Easy to scale

Page 8: Aspnet core developer workflow with docker

Benefits of using Docker for development• Getting an environment running very fast• Being able to share your environment with others• Being able to extend your environment very fast and easily (i.e.

adding a Redis server)• Consistent environments • You can version development environments • Development through Production

• Not polluting your computer with frameworks since they are installed in the containers (git & Docker is all you need!)

Page 9: Aspnet core developer workflow with docker

Open Container Initiative Docker is a runtime and container format based on the Open Container Initiative

Page 10: Aspnet core developer workflow with docker

Windows?• Docker now can also use the new container system in Windows

Server 2016 and Windows 10 (anniversary update), which can run Windows apps

Page 11: Aspnet core developer workflow with docker

Where can I host applications in containers?• Linux server• VM on Azure, AWS, etc. • Container service like AWS Container Service, Azure Container Service• Many other hosts (Hadoop, etc.)

Page 12: Aspnet core developer workflow with docker

Why ASP.NET Core and Docker? • You can now easily run .NET (Core) in a container, since it is cross-

platform• ASP.NET Core is very scalable and cloud optimized

Page 13: Aspnet core developer workflow with docker

How does Docker work?

Page 14: Aspnet core developer workflow with docker

Underneath Docker• Docker typically uses the Linux container system (i.e. LXC), which can

run apps that run on Linux (now it also uses the new Windows container system)• Linux containers isolate processes • Containers share the host operating system’s kernel - meant to create an

environment without the need for a separate kernel

Page 15: Aspnet core developer workflow with docker

Docker on Linux Containers• Docker helps manage containers• Docker abstracts machine-specific settings relating to networking, storing,

logging, etc. • Docker makes it easy to create and distribute containers

• Docker allows containers to run on many different machines, with many different configurations• 1 process per container philosophy

Page 16: Aspnet core developer workflow with docker

Docker on Mac and Windows• Docker runs containers on Linux kernel via virtual machine• They can now also run on the Windows kernel

Page 17: Aspnet core developer workflow with docker

How do Docker containers work? Images and containers

Dockerfile > Image > Container

• Dockerfile: text file recipe for image • Image: read-only file system (i.e. template)• Container: copy of an image (i.e. instance)

The container is what gets run and where apps go

Page 18: Aspnet core developer workflow with docker

Dockerfile

Runs when container starts

Runs when image is built

Page 19: Aspnet core developer workflow with docker

Images

Page 20: Aspnet core developer workflow with docker

Containers

Page 21: Aspnet core developer workflow with docker

You can develop with Docker on:

Page 22: Aspnet core developer workflow with docker

Docker basicsdocker images

docker ps -a

docker build -t <yourTag:ImageName> .

docker run -i -p 80:5000 -v $(pwd):/app -t <yourTag:ImageName>

docker rmi <image name>

docker rm $(docker ps –a)

Page 23: Aspnet core developer workflow with docker

Getting ready to develop in ASP.NET Core1. Install Docker & go to the command line2. Build an image by creating a Dockerfile & building3. Create/go into an app directory (create app if needed)4. Run the container. It will:

1. mount your directory 2. expose port(s)3. run and watch your app

5. Proceed to develop as usual in your IDE of choice

Page 24: Aspnet core developer workflow with docker

Demo

Page 25: Aspnet core developer workflow with docker

Docker Compose• Spin up multiple containers together • Declare container settings

Common commands:

docker-compose up -d

docker-compose stop

docker-compose down

Page 26: Aspnet core developer workflow with docker

Other common commandsdocker logs <container_name>

docker exec -it <container_name> sh

Page 27: Aspnet core developer workflow with docker

Demo

Page 28: Aspnet core developer workflow with docker

Thanks! @wynv | [email protected]

Resources: • Slides, http://www.slideshare.net/wynvandevanter/aspnet-core-developer-workflow-with-docker• BLOG: The Software Development Workflow with ASP.NET Core Using Docker, https://

www.excella.com/insights/the-software-developer-workflow-with-docker-and-asp-net-core• Self-guided ASP.NET Core (with Docker optional) Workshop, https://

github.com/excellalabs/aspnetcore-workshop-kit• An ASP.NET Core development environment Docker image,

https://hub.docker.com/r/wyntuition/aspnetcore-development-env/• Understanding Docker architecture for an explanation of its guts,

https://docs.docker.com/v1.8/engine/introduction/understanding-docker/Next Steps:

• Add a Dockerfile to a non-Windows-based app (i.e. .NET Core, Javascript, etc.)• Debugging an ASP.NET Core app running in a Docker container • Deploying containers on a hosted VM, AWS Container service, Azure Container Service, Heroku