TechBubbles Microsoft Technology BLOG

Docker containers deep dive

This post outlines basic overview on Docker containers , what benefits does it brings in using in your environment and what options we have for deploying them to Azure.

What is Docker?

Docker is self-service entity that can run on cloud or on-premise that can be used to host and run your applications. Docker basically contains two concepts.

1. Docker Images

It simply a file, where you package application and its dependencies.Docker Images are built based on layers. Example: if you have MusicStore application that built on .NET Core and runs on Ubuntu then layers looks as follows

Docker Images are built from Dockerfile. You can re-use DockerImages that other people build or you can create your own Docker Image by creating a Dockerfile. When you create a Docker Image then you give a name and tag.

Example: DockerDemo/musicstoreapp:1.0

Tagging allows you to create multiple images of different versions of same application. Docker Images can be published to a “Container Registry” allowing them to share with other developers. The container Registries can be either public or private.

DockerHub is an example of public container registry that contains thousands of popular open source images. Azure Container Registry is great place for storing private Docker Images.

For example, if you are building Micro services application then each of your micro service can build as container image and then can be published Azure Container Registry.

2. Docker containers

When you want to run the application , you create a container which is an instance of a Docker Image. Docker Container runs on “Docker Host” and uses the resources from it, so it provides CPU and Memory. It can also publish ports that allows network access to container instance. It also has disk access only districted to images only.

Docker Containers can restarted and stopped. You can delete when you do not need them.You can create multiple containers from a single image.What if Docker Container wants to store Data? Containers can use volumes to persist data.

When you are mounting volume then you can specify the path inside container. Example: var/data/sql. There are two types of containers Linux and Windows.

Docker Image works exactly same on any Docker Host. Docker Host can be your local development machine or virtual machine in AZURE or on-premise data center.

Note: Starting from Windows Server 2016, 2019 supports Windows containers. You can also run Linux containers on Windows containers.

What are my benefits using Dockers?

You might be wondering this is quite similar to Virtual Machines and it allows running applications along with their dependencies in an isolated way. Isolation, portability are similar in both containers and VMs.

Major difference is efficiency, running containers is much more efficient than running each application in each separate Virtual Machine. Containers use lot less disk space and lower memory requirement. You can pack 50 times of more containers on single host server than you could run Virtual Machines on same host server.

Containers are much faster to start, as there is no OS boot time involved. Containers are disposable and easily replace with new containers based on new version of software where as VMs require operating system patching. Containers less maintenance overhead.

Containers tends to be much secure compared to VMs. There are services available for containers to scan Vulnerabilities. Image signing also make sure they are coming from trusted publishers.

What are my options for managing Docker Containers?

Distributed applications contain multiple containers; typically, these applications do not run on single server but on cluster of servers for reason of scalability. Assume each server in cluster responsible for running different containers. Managing different containers is challenging, you need to know how to deploy, scaling to multiple servers, configuring networks and upgrading to new servers etc.

Thanks to Microsoft, you have following Orchestrators to do above work

  • AZURE Kubernetes Services  (AKS)
  • AZURE Service Fabric

Orchestrators contain cluster of Nodes and each is able to run containers. You communicate with Orchestrator and describe what containers required for your application. Whole application can defined in declarative way in Orchestrators using YAML.    

Image Source: markheath.net

Hosting options in AZURE

The options that to run containers in Azure are , first you can go to IaaS approach where you can install docker in Virtual Machine and use it.

Image Source: markheath.net

You can use Linux or Windows VMs to run your containers. You can spin up multiple VMs and orchestrate using Azure Kubernetes. Downside in this option is there is fair amount of overhead in managing these VMs.

Azure Container Instances are server less, you just mention what container that needs to run and behind the scenes, AZURE finds the server to the container. This is the fastest and easiest way to run the containers in AZURE. It uses per second billing model. This option is ideal and cost-effective if you want to run the container for short period.

If you are going to run your container for 24/7 then consider other hosting options. Azure Web Apps for containers great option for deploying web applications. It also allows you to get default features that are under App services such as custom domains and auto scaling etc.

Azure Service Fabric is a powerful Orchestration platform design to host distributed applications. It used to power own AZURE services such as Cosmos DB and Bing search engine services. It also support different programming models including micro services.

Azure Kubernetes Service (AKS) – it take away the work installing and configuring a Kubernete cluster. AZURE fully manages the control pipeline for you. All you need to do is mention the number of nodes that you need for cluster. It is best option if you already familiar with AKS and take the advantage of open source tooling

In the next post , you will get the sequence of steps that require to host a sample in AKS.

About the author

Kalyan Bandarupalli

My name is kalyan, I am a software architect and builds the applications using Microsoft .NET technologies. Here I am trying to share what I feel and what I think with whoever comes along wandering to Internet home of mine.I hope that this page and its contents will speak for me and that is the reason I am not going to say anything specially about my self here.

Add Comment

TechBubbles Microsoft Technology BLOG

Follow me

Archives

Tag Cloud