Tice Tips

What is Docker?

Docker, if you ever worked with hypervisors, the chance is that you’ve heard this term before. But what is it exactly? Before diving into the question “What is Docker?” it is essential to know the history and containers.

What are Containers?

In the early days of the internet, you would need to have various (physical) servers if you wanted to host multiple apps. Having multiple hosts, of course, tends to result in the wrong usage of resources. One of the biggest “eureka!” moments in the tech world were Virtual Machines. If you want to know more about Virtual Machines, you can read this explanation.

A drawback of Virtual Machines is that there is too much overhead and waste of resources. This overhead is because VM needs its OS, which contains files that the app you want to run does not require, as shown in the figure below. 

An image displaying the multiple layers of virtualization

Containers are a way to get all the benefits of Virtual Machines without all the overhead and waste of resources. Containers eliminate the need to run a whole OS when you want to host an app. You no longer need an entire OS because containers use a part of the OS to run. This means the containers don’t need to “Boot” because the OS is already running. In the figure below, you can find the (primary) structure of a containerized app. 

An image displaying the multiple layers of containerization

What is Docker?

Now that you know the basics of containers let’s move on to what the Docker Project is. The Docker Project provides all the components needed to run your apps inside containers. Docker consists of the following basic principles:

Dockerfile

Every Docker container starts with a Dockerfile. A Dockerfile is a file (without any extension) written in an easy syntax that allows you to build your container from scratch. At the beginning of a Dockerfile, there is a FROM command. This command is the base of your container, and it specifies the operating system that will underlie the container. After the FROM command, you are free to add whatever you want to the container. For example, you can copy your app files to the container so that the next time you start up your container, you can run your app inside. At the end of the Dockerfile, you can specify what command the container starts. You can do this with CMD. Below you will find an example of a Dockerfile:

In this example, we take the Ubuntu OS and copy our python app in the container. We use the make command to install the required software and dependencies. Finally, we use the CMD option to make the Python app run when you start the container. Next up, I’ll show you how to create an image from a Dockerfile!

Docker Image

An image is a read-only template with instructions for creating a Docker container. From a Dockerfile, you can create an image that you can use to start containers from. You can see an image as a blueprint for containers. 

In the previous chapter, I spoke of commands in a Dockerfile. Each of those commands (or instructions) creates a “Layer” when instructing the docker to build your image. This also means that if you change a single education in your Dockerfile, Docker only needs to rebuild that specific layer instead of the whole image. In the figure below, you will find a diagram of the layers inside an image.

An image displaying the multiple layers of a Docker image

Docker Hub

You don’t have to build every container from scratch. Docker Hub is a service you can where you can upload and download Docker Images. Docker Hub is a so-called “Registry”. A registry is an application that allows you to distribute images. On Docker Hub, you can find self-made images from other people and official applications from companies. 

Docker Hub is not the only place that you can use to store and share your Docker images. You can always choose to host your private registry!

Docker Client

The Docker Client is where all the magic happens!  The client is the primary way for people use to interact with Docker. Commands to build your images, start containers and push your images to the repository of your choosing start with the Docker Client. Initially, the client was only available on Linux, but they also have Windows and macOS clients.

Want to try all this for yourself? Docker provides you with a great “Getting Started with Docker” guide that will get you on your way 🙂

You may also like:

Palworld Xbox Dedicated Server Docker set up guide Palworld has been released in early access! But how do you start an Xbox

Palworld Dedicated Server Docker set up guide Palworld has been released in early access! But how do you start a server to

By Thijs van Loef
Posted on: 24/04/2021

No Comments on What is Docker?

Leave A Comment