Upload
wyn-devanter
View
302
Download
0
Embed Size (px)
Citation preview
Developer Workflow using Docker (with
ASP.NET Core)Wyn Van Devanter
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
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.
What is Docker?• A VM gives you a OS in a window• A container gives you a file system via background process(es)
VMs vs Containers• VMs are good at managing units of hardware resources • Containers are good at managing units of software
ContainersVirtual Machines
Benefits of containers• Consistent • Very portable • Fast to spin up • Smaller footprint • Easy to scale
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!)
Open Container Initiative Docker is a runtime and container format based on the Open Container Initiative
Windows?• Docker now can also use the new container system in Windows
Server 2016 and Windows 10 (anniversary update), which can run Windows apps
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.)
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
How does Docker work?
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
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
Docker on Mac and Windows• Docker runs containers on Linux kernel via virtual machine• They can now also run on the Windows kernel
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
Dockerfile
Runs when container starts
Runs when image is built
Images
Containers
You can develop with Docker on:
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)
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
Demo
Docker Compose• Spin up multiple containers together • Declare container settings
Common commands:
docker-compose up -d
docker-compose stop
docker-compose down
Other common commandsdocker logs <container_name>
docker exec -it <container_name> sh
Demo
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