问题
If I deploy an image built by choosing Alpine Linux as the base image on my Ubuntu machine (which acts as the host OS - where Docker is installed), will there be two kernels at play here - one from Ubuntu and another one from Alpine? I read that Docker containers will share the host Kernel, so I'm bit confused here.
If I login to a running container and issue another command, will this be another process from the perspective of the host OS? Or will this be another thread? From the perspective of the guest OS, I think it will be two separate processes.
Kindly clarify.
回答1:
A "container" is just an abstract term. It is just another process running on the Host (Ubuntu). Since your guest (Alpine) and Host (Ubuntu) both are Linux kernel based operating systems. Any command or program you run in the guest OS will be translated (by low level libraries) to system calls in the end and given to the kernel of the Ubuntu host.
A "container" is nothing but a group of processes to which the host kernel applies some common policies. So any command or program you run in the guest OS (as you call it) let's say
ping
will create a process on host with the same policies applied by the kernel as you container.
回答2:
They share your hosts kernel. Docker simply isolates group of processes into a container.
There is no guest OS, only a container. And processes run in docker containers just like they would run on your host. If you run
top
(on the host), you will see all processes running in docker containers as child processes of any given container.
来源:https://stackoverflow.com/questions/55586621/sharing-kernel-of-the-host-operating-system-while-using-docker