简体   繁体   中英

How and why OS being used as containers on docker

I have just started learning dockers and containers . It's make sense to me that I can containerized my application with all its dependencies and deploy it on docker engine and run it. But I am confused how OS such as UBUNTU is being deployed as container on docker? Because the basic concept what I understand is that, docker container is without or minimal OS dependencies for the application. Then why OS is also used as containers? Are the OS being treated as application on docker? or they have some other use and they just provide minimal dependencies for the application? It would be great if someone can explain this concept.

Linux systems contain Linux kernel and a set of programs/utilities on top of it, which define the overall behavior and look of the system. What makes Docker lightweight comparing to virtualization technologies is that it shares kernel with host OS. But not the rest of the programs.

You wouldn't probably want to deploy you app on pure kernel - you need POSIX api's together with shell and package manager. All this stuff comes with Ubuntu or whatever distro you prefer. So, containerizing your app you select best fitting Linux distro and use appropriate base docker image. Normally you consider the size, default package manager and rolling/stable deployment rules.

In fact, you can create your image with LFS or minimal code using FROM scratch directive, but I doubt this worth spent time.

So, returning to your questions:

But I am confused how OS such as UBUNTU is being deployed as container on docker?

Just mounted as a tar.gz rootfs

Then why OS is also used as containers?

To let you have package manager, glibc and other stuff. You like RUN apt-get install -y whatever , don't you?

Are the OS being treated as application on docker?

No, there is no application concept in Docker. Only main process, which keeps container alive. And OS is NOT treated as main process.

Docker will provide bare minimum version of os to deploy your application. Like if you use alpine(smallest image in docker), its around 5 MB size. You have to manually install other component specific to your application. Docker will provide you the platform to create a container. Inside the container its your wish what you want to use. You may use alpine or any advanced os like ubuntu then you can deploy your application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM