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 ToProgrammingSoftware

How To Write Clean Code

3 Mins read
Let’s look at tips and tricks on how to write clean code. Everyone wants to be able to write code that is…
How To

Is The Universe Infinite or Finite

3 Mins read
Table of contents0.1 What is cosmic inflation?0.2 How is space measured?0.3 Conclusion1 Don’t miss amazing tips! Is the Universe infinite or finite….
ComputingInteresting

How quickly will AI replace software programmers in future

3 Mins read
Table of contents0.1 How long before AI learns to program?0.2 Would machine-learning software programmers be needed?0.3 What skills will be needed by…

Leave a Reply

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

85 − = 78

×
ComputingSoftwareTechnology

Basics on What Docker Is And Why People Use It