An Introduction to docker 🐋

A brief introduction to Docker, a software that has revolutionized container management on personal computers to the cloud.

Vishesh Dhawan
Vishesh Dhawan
July 19, 2021
docker

    Share

Long gone are the days of Linux container management, with the rapid increase in popularity of cloud technology we know that we need more robust solutions for containerization of our apps along with all the tools needed for their management and docker is our best bet to achieve this. 🔥

Why do we need containerization??

Compute resources are the backbone of the cloud. On AWS (amazon web services) we have Amazon Elastic Compute engine (EC2) which allows us to launch virtual machines in the cloud and make scale computing easier for developers.

Similarly, in Google Cloud Platform we can create virtual machines with the compute engine.

We choose an operating system and also other resources like RAM and the number of CPUs for that virtual machine. Cloud services provide us with all the necessary tools to manage our virtual machines and provide security to them.

The problem with virtual machines

The biggest problem with running virtual machines(VM) is scalability. For e.g. Imagine that the app you built on the VM, gains popularity and its users increase so much that they max out the CPU and memory of the VM.

One option is to make the VM more powerful by adding more CPUs and memory to the VM. This is called Vertical Scaling.

The other option is to create more VM’s and distribute the workload among them. This is known as horizontal scaling.

With horizontal scaling comes the problem of load balancing i.e. one VM gets most of the traffic while others just sit idle.

Containerization lets us free of worrying about scaling our infrastructure at all
containers

Docker comes into play

Containerization is defined as a form of operating system virtualization, through which applications are run in isolated user spaces called containers, all using the same shared operating system (OS). Every container is isolated from the other.

According to Docker:

A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another.

I know you might be thinking that they both sound the same, but there are major differences under the hood:

  • Every docker container shares the same system resources. Therefore, every container has access to complete system resources.
  • They do not have complete operating systems inside.
  • They are very lightweight as compared to virtual machines because they only contain application-level dependencies.

How the containers work is a more complicated concept, and here I’m not going into that.

containers vs virtual machines

Docker allows the developers to put their applications in a container and then deploy it to any cloud service. The clouds have container registries where we can upload our containers and use them across different services.

Docker Hub

Docker hub is a service provided by Docker for finding and sharing container images with your team. It provides the following major features:

  • Repositories: Push and pull container images.
  • Teams & Organizations: Manage access to private repositories of container images.
  • Official Images: Pull and use high-quality container images provided by Docker.
  • Publisher Images: Pull and use high-quality container images provided by external vendors. Certified images also include support and guarantee compatibility with Docker Enterprise.
  • Builds: Automatically build container images from GitHub and Bitbucket and push them to Docker Hub.
  • Webhooks: Trigger actions after a successful push to a repository to integrate Docker Hub with other services.

Installing Docker

Install Docker Desktop on windows

1. System Requirements

  • Windows 10 64-bit: Pro, Enterprise, or Education (Build 15063 or later).
  • Hyper-V and Containers Windows features must be enabled.
  • The following hardware prerequisites are required to successfully run Client Hyper-V on Windows 10:
  • 64-bit processor with Second Level Address Translation (SLAT)
  • 4GB system RAM
  • BIOS-level hardware virtualization support must be enabled in the BIOS settings. For more information, see Virtualization.

2. Installation

  • Double-click Docker Desktop Installer.exe to run the installer.
  • If you haven’t already downloaded the installer (Docker Desktop Installer.exe), you can get it from Docker Hub. It typically downloads to your Downloads folder, or you can run it from the recent downloads bar at the bottom of your web browser.
  • Follow the instructions on the installation wizard to accept the license, authorize the installer, and proceed with the install.
  • When prompted, authorize the Docker Desktop Installer with your system password during the install process. Privileged access is needed to install networking components, links to the Docker apps, and manage the Hyper-V VMs.
  • Click Finish on the setup complete dialogue and launch the Docker Desktop application.
docker installed
  • When the whale icon in the status bar stays steady, Docker Desktop is up and running and is accessible from any terminal window.

Some basic docker commands

  • “docker run” — Runs a command in a new container.
  • “docker start” — Starts one or more stopped containers
  • “docker stop” — Stops one or more running containers
  • “docker build” — Builds an image from a Docker file
  • “docker pull” — Pulls an image or a repository from a registry
  • “docker push” — Pushes an image or a repository to a registry
  • “docker export” — Exports a container’s filesystem as a tar archive
  • “docker exec” — Runs a command in a run-time container
  • “docker search” — Searches the Docker Hub for images
  • “docker attach” — Attaches to a running container
  • “docker commit “– Creates a new image from a container’s changes

Conclusions

Overall Docker is an awesome tool that makes a developer’s life easier and more productive. There are tools like Kubernetes which organizes our containers into groups of pods and can automatically scale those pods based on the amount of traffic or utilization. While the developers can sit back and have a cup of coffee.

I highly encourage you to use docker in your projects as well. 💯