How Docker Works: Making Your Apps Compa ...

How Docker Works: Making Your Apps Compatible Anywhere

Oct 14, 2023

Have you ever considered the concept of containerizing applications and running them without conflicting with the underlying operating system? If not, don’t worry; In this short blog, we’ll go into the meaning of this idea and examine how it works.

Understanding Traditional OS Architecture

If we dive into the operating system, it consists of the hardware infrastructure at its core. On top of that, there is an OS kernel that communicates with the hardware. Furthermore, various software components come together to form a complete operating system, which we interact with through a user interface, such as Ubuntu, Kali, Windows 7, or Windows 10.

© Copyright above Image owner is https://www.javatpoint.com/


In case of Docker we have something like following.

© Copyright I am not the owner of Image

Docker acts as a middle man between the container and the OS kernel. In other words, it shares the underlying OS kernel with the host system but does not share top-level software like Kali, Linux or Windows. This setup allows Docker to run applications without causing conflicts or problems. Essentially, Docker keeps applications in their own little world, separate from the underlying operating system, which helps avoid problems and compatibility issues.

Lets Understand it with Example:

Suppose you have a web application, and it runs on a Linux operating system. You built and tested it on Ubuntu 18.04, but your production environment runs on Ubuntu 20.04. In this way Docker helps you eliminate the underlying OS version and save you headaches.

First, you create a Docker image for your application. This image contains your application code, its dependencies, and the runtime environment. You can specify the base image to use.

FROM ubuntu:18.04

# Install dependencies and set up your application
# ...

CMD ["/path/to/your/application"]

When you create a Docker image, it essentially wraps your application in an isolated environment with a specific version and runtime setup. This means that even if your host system is running Ubuntu 20, the container ensures that your application behaves as if it were running on Ubuntu 18.04. In this way, Docker makes your application run consistently on different machines, and it simplifies the process of deploying your application on any computer. All you need to do is run a simple ‘docker image’ command to create an image using a Docker file, and your application is good.

Conclusion:

I hope you know understand the concept of how docker abstract the underlying OS. I know this one was short but it will help you understand basics of Docker and will help you in your devops journey.

Vous aimez cette publication ?

Achetez un café à iamyounus

More from iamyounus