데이터 엔지니어링/Docker

[Docker] Container의 Lightweight (컨테이너가 가벼운 이유)

pythaac 2022. 7. 14. 19:58

요약

Container에 포함되는 OS 이미지에는 kernel이 없으며, host kernel을 공유하여 사용하므로 가볍다. Container의 OS와 host의 kernel이 충분히 호환되면 동작하며, 그렇지 않을 경우 동작하지 않는다.

 

컨테이너가 가벼운 이유?

컨테이너는 머신 OS system의 kernel을 공유하므로 application마다 OS를 필요로 하지 않고, 따라서 서버에 더 효율적이고 서버의 수와 라이센스 비용을 줄인다.

Containers share the machine’s OS system kernel and therefore do not require an OS per application, driving higher server efficiencies and reducing server and licensing costs

https://www.docker.com/resources/what-container/

 

What is a Container? - Docker

A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing

www.docker.com

 

Host OS의 kernel을 공유?

Docker는 host OS의 kernel을 사용하며, 컨테이너 내부에 커스텀 혹은 추가적인 kernel을 가지지 않는다. 실행되는 모든 컨테이너들은 host의 kernel을 공유한다. Docker는 cgroups, kernel namespace와 같은 Linux kernel의 resource isolation 기능을 사용하여 VM 없이 컨테이너를 하나의 Linux 인스턴스로 실행할 수 있도록 해준다.

Docker uses host OS kernel, there is no custom or additional kernel inside container. All containers which run on a machine are sharing this "host" kernel.
Docker uses resource isolation features of the Linux kernel such as cgroups and kernel namespaces to allow independent "containers" to run within a single Linux instance, avoiding the overhead of starting virtual machines.

https://www.quora.com/Do-Docker-containers-have-their-own-kernel

 

Do Docker containers have their own kernel?

Answer (1 of 5): No, it makes use of the Host kernel for resources and kind of acts like software in the Host system. This, unlike a VM which has its own Kernel, So it is completely isolated from the Host system. If you see the architecture of the OS in wh

www.quora.com

 

Ubuntu/Redhat과 같은 image도 kernel이 없는지?

Docker image는 kernel을 포함하지 않으며, container 또한 kernel을 실행하지 않는다.

Docker images (including the ubiquitous ubuntu and debian images) don’t contain kernels, and containers based on them don’t run kernels; they always share the host kernel.

https://forums.docker.com/t/are-the-images-of-full-operating-systems/26686/7

 

Are the images of full operating systems?

Docker images (including the ubiquitous ubuntu and debian images) don’t contain kernels, and containers based on them don’t run kernels; they always share the host kernel. You need to go through special setup to be able to use host devices, regardless

forums.docker.com

 

Host OS와 Container의 kernel 이 맞지 않으면?

만약 container의 application과 host kernel이 "충분히 호환되면" 동작한다. 그렇지 않으면 동작하지 않는다. ... "충분한 호환"은 application의 system call기대하는 kernel 기능에 따라 다르다. ... 예를 들어, Ubuntu 18.04 (kernel 4.19)에서 다음과 같은 차이를 보인다.
* docker run centos:7 bash 는 동작한다.
* docker run centos:6 bash 는 동작하지 않는다.
* docker run centos:6 ls 는 동작한다.

If your host kernel is "compatible enough" with the software in the container you want to run it will work; otherwise it won't. ... So what does "compatible enough" mean? It depends on what requests the program makes of the kernel (system calls) and what features it expects the kernel to support. For example, on an Ubuntu 18.04 (kernel 4.19) or similar host:
* docker run centos:7 bash works fine.
* docker run centos:6 bash fails with exit code 139, meaning it terminated with a segmentation violation signal; this is because the 4.19 kernel doesn't support something that build of bash tried to do.
* docker run centos:6 ls works fine, because it's not making a request the kernel can't handle, as bash was.

https://stackoverflow.com/questions/32841982/how-can-docker-run-distros-with-different-kernels

 

How can Docker run distros with different kernels?

How can docker run on a Debian host maybe an OpenSUSE in a container? It uses different kernel, with separated modules. Also older Debian versions have used older kernels, so how can run it on a ke...

stackoverflow.com

 

'데이터 엔지니어링 > Docker' 카테고리의 다른 글

[Docker] Base Image (Scratch)  (0) 2022.09.19
[Docker] Docker Daemon (dockerd)  (0) 2022.07.14
[Docker] Docker 정리 (정의/아키텍쳐)  (0) 2022.07.12
[Docker] 윈도우 docker 설치  (0) 2022.06.16
[Docker] 명령어 모음  (0) 2022.05.13