Technology

What Is Docker & How Do We Start With It?

This is a beginner-level guide to help you understand Docker. After reading this blog post you will be able to understand what Docker and its advantages are at a fundamental level. You will know the benefits of Docker over the legacy systems and the steps on how you can install Docker on any Linux-based platform and deploy and use a container, which will be a set of networking tools that one can use from within the container.

What is Docker?

To put it very simply, Docker is a tool to build and deploy applications. The idea which it is based on is that one can combine their code for the application along with its dependencies into a single component called a Container which is deployed on the Docker platform.

Docker Architecture

Think of it this way, the developer puts the application code and its dependencies in a container, and when you open the container, it runs exactly the way it was intended to run along with other containers on the ship.

Docker Terminology

Docker Daemon
Docker daemon can be called a service that is executed on the host operating system (e.g., If you install Docker on a laptop running Ubuntu, then the host OS is Ubuntu). Earlier Ubuntu ran only on Linux-based OS but thanks to WSL, it can now run on Windows too. The dependency on a Linux platform is because Docker uses several Linux kernel features. The Docker daemon communicates with the host OS by exposing its own REST API.

Docker Container
Containers are used to run, deploy and create an application on Docker. A developer is enabled by containers to combine all the parts of an application required to run it for example any dependencies and other libraries and ship it as a single container.

Docker Hub
Think of Docker Hub as an App Store or for example, a manufacturer develops their product and puts them in a store where you can choose which one you would like to purchase. Similarly, Docker Hub is kind of like a store but cloud-based one where a developer pushes their images/build to by linking to the code repositories and can also build and test their images there, after which you can pull those images to run on your Docker installation.

Advantages of Docker

Again, going with the manufacturer analogy, think of yourself as a shoe manufacturer and want to build your own brick and mortar store to sell them but the cost is too much to build and maintain your own store. So, you go to a mall where you think of leasing a store for your shoes, but soon realize that an entire store is a lot of space and the rent, utilities are still a huge overhead. So now you go to one of those multi-brand stores and ask them to stock your shoes among other merchandise where the owner charges you only for the slots where you want to display your shoes.

Docker

So similarly, if you’d want to build and host a website or build an app., you will have to buy your own servers (brick and mortar) which is too expensive then you think of using services like Hostinger, GoDaddy.com, etc. to host your website. The other option available is to host your website at cloud-based services such as Amazon Web Services (AWS) where they use virtualization (leasing store at the mall). But even with virtualization, you have the host OS on top of which AWS runs the hypervisor on top of which your VM runs with its own OS which ultimately hosts your website or app. The OS overhead is still high for your website.

That is where Docker helps, its Docker Engine runs on top of the host OS on top of which your app/website can run (multi-brand store), eliminating the guest OS overhead.  

Install Docker

To install Docker on your machine with a Linux-based OS ideally you’d want to SSH quickly into your machine, which has been described in my previous blog post. Docker is supported on the x86_64 (or amd64), armhf, and arm64 architectures.

Install Docker

Now there are multiple ways by which you can install Docker on your system, but to keep things simple we will be using the repository method to get Docker. Follow these steps and enter the commands to get Docker up and running:

  • Update the apt package index and install packages to allow apt to use a repository over HTTPS:
    • $ sudo apt-get update
  • Add Docker’s official GPG key:
    • $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg –dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
  • Depending on your architecture (arm64) use the following command to set up the stable repository:
    • $ echo “deb [arch=arm64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu    $(lsb_release -cs) stable” | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  • Install Docker Engine
    • $ sudo apt-get install docker-ce docker-ce-cli containerd.io
  • Verify your Docker install
    • $ sudo docker run hello-world

Looking Forward

In my next blog post, I will be explaining how to install a container (useful networking tools) and how to use Docker using a graphic user interface (GUI). Hopefully, after reading the blog, you will be able to understand and explain the concept of Docker to someone else and get an installation of Docker running for yourself. There can be many issues regarding this installation, if you have any please reach out to us or you can even call for business at +919773973971 to help you with any help you might have related to Docker or Cloud-based Services.

Author
Anant Seth
Network Consultant Engineer

Author

Team ZT