What is docker?

Docker is an open-source virtualization software used for developing and deploying applications. To put it simply docker enables easy development and deployment of applications inside neatly packaged virtualized containers that contain all the dependencies of the application to run without many problems.

Docker containers can be deployed to any machine running with different environment configurations without any compatibility issues. This is one of the main reasons why software developers use docker as software is easy to deploy.

The docker containers running on your server or computer act like individual computers with their operating systems and isolated CPU processes, memory, and network resources. Because of this, they can be easily removed, started, stopped, and added without affecting each other or the host machine.

Why should you care about Docker?

Suppose you are a developer at a company. You would normally install some dependencies configure your environment and then build and run your code on your host machine. After testing, your code would run just fine. When a software tester would try to run your code on their machine, it would in some cases not run on their machine. This is due to the different environments from the developer to the tester.

The solution would be to package your application onto docker and this would solve the incompatibility issues at both ends.

Docker VS Virtual Machines (VMs)

At a glance, docker and virtual machines may look similar. Both serve to address a thing known as virtualization but with different approaches.

Here are some reasons why you would use docker over virtual machines:

  • Virtual Machines occupy more space on the host machine compared to docker containers which are usually smaller and lightweight and occupy significantly less memory space.

  • Virtual Machines have longer boot times compared to docker which has significantly shorter boot times.

  • Running multiple Virtual Machines may lead to system instabilities as docker containers have better performance as they are hosted in a single docker engine.

  • Virtual Machines can be difficult to scale up compared to docker which can be easily scaled up.

  • Virtual Machines may have compatibility issues while porting across different platforms while docker containers are easily portable across different platforms.

Virtual machines (VMs) and Docker containers are virtualization technologies, but they have different use cases and benefits. Whether virtual machines are better than Docker or vice versa depends on your specific needs and use cases. Here are some reasons why virtual machines are preferable to Docker:

  • Virtual machines provide stronger isolation between applications and the host operating system. Each VM runs a full guest operating system, which may differ from the host operating system. This isolation is beneficial for security and compatibility when running applications with different operating system dependencies.

  • Virtual machines are managed by hypervisors that can provide advanced features such as live migration, snapshots, and more. These features are useful in enterprise environments where high availability and fault tolerance are critical.

  • Virtual machines enable strict resource allocation and isolation. Each virtual machine can be allocated a specific amount of CPU, memory, and storage resources, which can prevent a virtual machine from consuming all available resources on the host.

  • Virtual machines can run any operating system virtually, making them a versatile option for running legacy applications or specialized software that may not be packaged in containers or have strict operating system requirements.

  • Virtual machines offer full control over the guest operating system. This can be beneficial when you need to configure the operating system to meet specific requirements or perform low-level system operations.

  • Virtual machines can provide a higher level of security by separating the guest operating system from the host operating system. This can be important for applications with high-security requirements.

  • Virtual machines can run Windows-based environments, which can be difficult to contain with Docker due to the different operating system architecture.

  • Virtual machines are suitable for running legacy applications that require a specific operating system version or custom configurations that are difficult to replicate in a container.

  • Virtual machines are suitable for running multi-tenant applications because they provide strong isolation between each tenant's environment. This makes them a good option for hosting or cloud service providers.

How to Install Docker

This brings us to the installation of docker on your host machine. To use docker in practice we would first have to download and install docker on your host machine/ local machine.

Because docker gets updated all the time, the installation may change as per the time this article is written. It is best practice to refer to the latest installation guide provided on the official docker page.

All you have to do is open your browser and search “Docker install” or navigate to https://docs.docker.com/engine/install/ and follow the installation process depending on what operating system you are installing.

Once your installation is complete, we can start running some simple docker commands on your machine.

Docker Images vs Docker Containers

Docker allows us to package an application with its environment configuration in a package that can be easily shared or moved.

To simplify what exactly a docker image is, suppose you create a zip file (an application artifact) which you can then upload to cloud storage and later download locally or to a server. In the process, the application artifact we produce with docker is what we refer to as a docker image but in the case of the application artifact created by docker contains the application source code and the environment configuration.

When we download the docker image onto our local machine or server, we want to run the application on our computer. When we run the image on our operating system the application inside the docker image starts in the pre-configured environment.  This gives us the docker container. In essence, a running instance of a docker image is the docker container.

Docker Registry

Now that we have a basic understanding of what docker images and containers are, you may now be wondering how to get a docker image to run a docker container. Suppose you want to run a Python container, this is where docker registries come into play. To put it simply, docker registries are a storage and distribution system for docker images. These registries are developed and maintained by companies like Mongo and Postgres to name a few and also by software authors in collaboration with the docker community. These are officially verified images. These images can be obtained from the docker hub  https://hub.docker.com/.

Conclusion

In this short article, we learn what docker is and how it differs from virtual machines. We also learn its advantages and where to obtain all the docker resources. In future articles, we will dive deeper into docker and learn the different docker commands and how to use docker images to package Python applications.

If you found this article helpful consider subscribing and sharing.

Thank you 😉