Modernising with Containers

Modernising with Containers

In this article, we will explore some reasons to consider containers and help you get started with it.

Why Containers?

Gartner predicts that by 2022, more than 75% of global organizations will be running containerized applications in production

Just because Gartner says it does not mean we should do it, not all their predications turn true! So why should we do consider containerisation?

For that, we should look at what's happening at Cloud front, several organisations have already embarked on their journey to Cloud, and for most Lift and Shift (VM on Prem -> VM on Cloud), has been an easy entry into Cloud Datacenter.

While being in Cloud itself is a big win in terms of scalability and efficiency, the next logical step "Cloud Optimise" is to explore options to improve productivity and reduce costs.

Cloud Maturity Model

This is where they start thinking about Cloud Maturity

  1. Lift and Shift: Least effort for quick migration usually Infrastructure as a Service (IaaS), easy entry into Cloud Datacenter
  2. Cloud Optimised - Increased density & lower deployment cost, Improved productivity and DevOps agility. Containers are great fit here!
  3. App Modernisation: Re-Architecting Apps an modify code to utilize SaaS and PaaS services, eliminate the overhead of managing and maintaining Operating System and Database platforms and optimised applications for long term agility, scale and high availability.

If you are interested in reading more Modernize existing .NET applications with Azure cloud and Windows Containers is a great book that explains these concepts in depth.

If you need to speak to business why they should support Cloud Optimise initiative show them the picture below (thank you!)

Cloud Maturity Model - Benefits

Now let's look at same the same question about Containers from technical aspect.

What is a Container?

Containers get their name from the shipping industry where the problem was - I have different things I want to ship, and there are all these different ways of shipping it. How do we create a universal way to ship anything by any method?

So, the industry created a shipping container. It’s a known size and shape. You can put whatever you like in it, and every shipping method is designed to handle this crate.

A really smart person stole this idea and introduced it to us techies as a container (same analogy - same picture different things!).

The idea is really simple, you construct a deployable unit called Container with all your code's dependencies and place your application inside it. Now you can run this application on my machine's, Jo Blogg's Machine and someone else's machine too.

Now let's give that smart person bit more credit. When you think of containers think of four things

What is a Container?

1. Runtime Isolation: It is a sandbox for a process and is achieved using two concepts

  • Namespaces isolation — that provides the ability to isolate process so it gets own view of the world and generally can’t modify or view another one.
  • Control Groups — provides the ability to partition resources such as compute and memory so that the container cannot monopolize a machine’s resources.

2. Images: Very simply binary representation same as how we have images for our VMs.

It is build using Layer Capabilities and has a notion of a parent-child relationship. You build on top of parent image e.g., above WordPress is built on top of Nginx image (IIS like). For Devs think of it like Image is a Class (blueprint) and Container is Instance of Class i.e. Object.

3. Dockerfile: It is an environment in a text file and is a starting point for an image.

The start of the docker file is "From" i.e. parent image this docker file is inheriting from and every line of docker file is defining a layer in your container.

4. Container Engines: Finally, Docker is not the only Container Engines there are others e.g., rocket, ContainerD, Mesos DC/OS etc. However, Docker, it is the most popular and commonly used one.

Docker Commands

There are three categories of command we need to know

Docker Cheat Sheet
  1. Build – How do I build Image from Docker File
  2. Run - How do run docker container using image
  3. Share – How do I share it with other / publish it

What is Container Registry?

Simplest way to explain Container Registry is - it's a common place for you and team to manage Container Images. Like with any share it can be private or public and there are several providers that help you host them e.g., Docker, Azure Container Registry (Azure ACR), Amazon Elastic Container Registry (Amazon ECR), Google Container Registry and more... key thing to remember is they need to be secure & highly available.

Hands-On Practice

If you feel that is a lot of theory and just want to try hands-on. No problem! I got you covered. Below are two simple labs (should take less than 30 mins).

Click the link below and try

  1. Getting Started with Docker
  2. Multi-Stage Builds
Docker 101, lets get started! Contribute to kunalbabre/Docker-101 development by creating an account on GitHub.

Share Tweet Send

Related Articles

You've successfully subscribed to Kunal Babre
Great! Next, complete checkout for full access to Kunal Babre
Welcome back! You've successfully signed in
Success! Your account is fully activated, you now have access to all content.