docker study notes - basic concepts

1. Containers and virtual machines

Both can provide a virtual, relatively independent computing environment to realize the management and configuration of software and hardware resources.

Containers are lighter, easier to install, easier to configure, and require fewer resources.

2. What is docker

Docker is an implementation of container technology. The three most important concepts are:

  • Mirror image - environment configuration, created by dockfile.

  • Containers - running images

  • Warehouse - Centralized storage of images for download and exchange

3. Why can docker build different environments such as ubuntu, centos, etc.

First you need to distinguish between the Linux kernel and the Linux distribution

  • The Linux kernel is the core of the Linux operating system, responsible for hardware management, such as managing memory, managing disk (file system), managing CPU (process), etc...

  • The Linux distribution adds some tool software on the basis of the Linux kernel, such as graphical interface, function library, software package management system, etc...

CentOS and Ubuntu are different Linux distributions, they are both based on the Linux kernel, but the tools added are different. For example, their package management systems are different, CentOS uses yum command to install software, while Ubuntu uses apt-get command to install software.

Therefore, the kernels of CentOS and Ubuntu are the same (the version may be different), but the installed software is different, that is, the file system is different.

Docker container technology is implemented based on the Linux kernel, which mainly uses two kernel modules:

  • Namespace: It is used for container isolation, such as PID Namespace, so that the process in the container cannot perceive the process in the host and other containers.

  • Cgroups: Used for container resource control, such as limiting the memory size or the number of CPUs used by the container.

When running an Ubuntu image-based container on CentOS, the container uses the kernel of the CentOS host and the Ubuntu image, and various Ubuntu software (apt-get) is installed in the Ubuntu image.

Docker is a process-level isolation. Although other containers cannot be seen in the container, the host system can see the process running in the container.

Docker mainly isolates several aspects:

  • Isolation of process number - the process number recognized by the process running in docker is changed

  • File system isolation - docker creates a virtual file system, the principle of mounting?

  • Isolation of network resources - the container has its own ip address, etc.

Guess you like

Origin blog.csdn.net/reverie_2007/article/details/128680143