1
ComputingHow ToSoftware

How Docker Works In A Local Machine, Namespacing And Cgroups

2 Mins read

Have you ever wondered how docker works in a local machine? What is namespacing and cgroups? In this article, we’re going to walk through how Docker works on a local computer that does not have linux as it’s primary Operating system.

How Docker Works In A Local Machine

There are two primary pieces of technology we need to talk about, first – is the namespacing in Linux kernels and the second is cgroups. Though we will not go into details in this article, it is important to know that these two are key in Docker operations.

Namespacing

Namespacing is a technique (and technology) which containers use to create an abstraction of the underlying host. Namespacing maps a portion of the kernel’s  namespace  to provide isolation between processes running in isolated “containers”. Let’s take a quick look at what namespaces are.  Namespaces are kernel objects which allow the whole of the kernel to be divided into smaller parts.

The namespace specifies an area of the kernel that can be used to restrict access to system resources, such as processes, network connections, inter-process communication (IPC), devices and files.


Namespaces are always stored in files in /proc .  More information on namespaces can be found here.

Cgroups

Once again, it is a technology that provides control over system-level resources by grouping them hierarchically.
The second piece is Linux Control Groups – also  known as LXC containers – which are used with Docker’s cgroups  technology to provide resource allocation to processes that are running within “containers”.
More information on cgroups can be found here.

This shows how docker utilizes namespaces and groups on linux.

If both namespaces and cgroups are linux specific commands, how does docker run on Mac/Windows?

Docker uses another driver by the name of Kernel Streaming (Kernel Streaming is a technology that allows sharing of kernel memory between processes.) This driver is embedded into Docker. As such, it enables containers to run as any other process on that host machine (Linux).

If you want to create a container with cgroup support for Mac and Windows, we need to install Linux Virtual Machine on Mac and Windows, and then the linux kernel will host the different processes for the containers.

How can you check which Linux version is running as a virtual machine to host the Docker on your local machine? – You can simply do the below.

Open up terminal and type.

docker version

The OS shows the virtual machine that Docker containers are running on. As you can see, it shows linux, even if I am currently running this on MacOs.

Conclusion

In a very basic sense, that is how docker runs on your machine, to learn more about basic docker commands, see this article.

Don’t miss amazing tips!

1
Related posts
How ToProgrammingSoftwareTechnology

How to configure Apache Airflow on MacOS locally

4 Mins read
Table of contents0.1 Creating the project folder and the virtual environment0.2 Installing0.3 Running airflow0.4 Starting the webflow server0.5 Starting the scheduler0.6 Running…
Code ChallengesHow ToProgrammingSoftware

How To Implement Merge Sort and Quick Sort Algorithms In Python 3

3 Mins read
Table of contents0.1 Merge Sort0.2 Quick Sort0.3 Conclusion1 Don’t miss amazing tips! Let’s have a look at how to how to implement…
InterestingSoftwareTechnology

Getting started with TensorFlow, amazing basics

4 Mins read
Table of contents0.1 What is a Tensor?0.2 What is TensorFlow?0.3 How many models can I train with TensorFlow?0.4 How do I use…

Leave a Reply

Your email address will not be published. Required fields are marked *

+ 10 = 20

×
ComputingHow To

How to install Docker for Windows/Mac