Docker – What is it and why is it so good?

docker headline

Learning what is and what is not docker, and why is it so popular?

2 0
Read Time:3 Minute, 28 Second

Every developer has struggled with wrestling infrastructure. The application that runs so well locally simply fails in UAT or worse, in the production environment. More so when it’s a cross-platform solution. I used to work on a Windows machine and had to deploy my java web app to Solaris. Even though Java is a cross-platform solution, there are slight differences here and there when it’s running on a different platform. It’s always a challenge to perform regression test on Solaris to make sure everything works exactly as I intended.

Introduction

Docker solves this problem. Docker Engine enables containerized applications to run anywhere consistently on any infrastructure, solving “dependency hell” for developers and operations teams, and eliminating the “it works on my laptop!” problem.

Container vs Virtual Machine

Containers and virtual machines have similar resource isolation and allocation benefits, but function differently because containers virtualize the operating system instead of hardware. Containers are more portable and efficient.

Container

Container is an abstraction at the application layer that packages code and dependencies together. Multiple containers can run on the same machine and share the OS kernel with other containers, each running as isolated processes in user space. Containers take up less space than VM, can handle more applications, and require fewer VM and OS.

Virtual Machine

VM is an abstraction of physical hardware turning one server into many. The hypervisor allows multiple VMs to run on a single machine. Each VM includes a full copy of an operating system,  the application, necessary binaries and libraries. Taking up tens of GB, slow to boot, and expensive to run.

Container and Virtual Machine

Container and Virtual Machine are not exclusive. In fact, they work well together to create great flexibility in deploying and managing applications.

Why is it so popular?

Docker sparks the movement of containerization – writing applications that run in the Docker engine. The reason? Dockerized applications are easier to test, and deploy. It’s generally worth it to spend a little more time upfront setting up docker and containerize application and reap the rewards down the road during testing and deployment.

Another reason to write a container-friendly application is that it is very easy to scale applications in a container. Since the application is platform-agnostic, and all dependencies are bundled into the docker image, it is easy to spin up another instance of the variable in the same or different machine. If this sounds like a good microservice solution to you, it’s because it is! Docker works very well with microservice and many have adopted docker for building microservices.

All you need to scale is to place a load balancer in front of the application and the application can now achieve high availability and is more resilient.

Kubernetes is an open-source container orchestration system for automating application deployment,  scaling, and management. It manages Docker containers. It can automatically spin up a new instance of your application in docker, and configure load balancer to include the new instance.

How to install docker in Windows

Note
If you have installed Bluestack or similar virtualisation tool before, you might have disabled Hyper-V auto start. Enable it back with PowerShell:
bcdedit /set hypervisorlaunchtype auto

  1. Search for “Turn Windows Features on or off” in Start and open the first setting that pops out
  2. Tick Windows Subsystem for Linux and Hyper-V
  3. Restart Windows
  4. Open PowerShell and run the following command wsl --set-default-version 2
  5. Open Microsoft Store and install Ubuntu
  6. Launch Ubuntu, on the first launch, you will be prompted to enter username and password
  7. Download and install Docker Desktop for Windows
  8. Optionally, download and install docker-compose.
    1. Docker-compose is a convenient way to store docker run configuration in a file and manage container lifecycle easily

Run your first container application

  1. Open WSL console
  2. Run $ docker run hello-world
  3. You will see a message from docker if you installed everything correctly

What’s next?

Congrats on running your first docker application!

Next, you might want to explore some open source project out there runs in docker.

  1. Pihole (https://hub.docker.com/r/pihole/pihole)
    Open source network-wide Ad Blocking
  2. Monica – https://github.com/monicahq/monica
    Monica is a great open-source personal relationship management system
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %
how to design database table banner Previous post How to design a database table?
Next post Design Pattern: Adapter Pattern. How I use a simple pattern to write flexible, maintainable, and high-performance code.

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

Your email address will not be published. Required fields are marked *

Menu