简体   繁体   English

如何以及为何将OS用作Docker上的容器

[英]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. 对我来说,我可以将应用程序及其所有依赖项容器化,然后将其部署在docker引擎上并运行。 But I am confused how OS such as UBUNTU is being deployed as container on docker? 但是我很困惑,像UBUNTU这样的操作系统是如何作为容器部署在docker上的? Because the basic concept what I understand is that, docker container is without or minimal OS dependencies for the application. 因为我了解的基本概念是,Docker容器对应用程序没有或只有最小的操作系统依赖性 Then why OS is also used as containers? 那么为什么OS也被用作容器? Are the OS being treated as application on docker? 操作系统是否被视为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. Linux系统包含Linux内核以及位于其之上的一组程序/实用程序,它们定义了系统的整体行为和外观。 What makes Docker lightweight comparing to virtualization technologies is that it shares kernel with host OS. 与虚拟化技术相比,使Docker轻巧的是,它与主机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. 您可能不想在纯内核上部署您的应用程序-您需要POSIX api以及shell和包管理器。 All this stuff comes with Ubuntu or whatever distro you prefer. 所有这些东西都随Ubuntu或您喜欢的任何发行版一起提供。 So, containerizing your app you select best fitting Linux distro and use appropriate base docker image. 因此,对您的应用进行容器化时,您选择最合适的Linux发行版并使用适当的基本docker映像。 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. 实际上,您可以使用FROM scratch指令使用LFS或最少的代码来创建映像,但是我怀疑是否值得花时间。

So, returning to your questions: 因此,回到您的问题:

But I am confused how OS such as UBUNTU is being deployed as container on docker? 但是我很困惑,像UBUNTU这样的操作系统是如何作为容器部署在docker上的?

Just mounted as a tar.gz rootfs 刚挂载为tar.gz rootfs

Then why OS is also used as containers? 那么为什么OS也被用作容器?

To let you have package manager, glibc and other stuff. 让您拥有包管理器,glibc和其他功能。 You like RUN apt-get install -y whatever , don't you? 您喜欢RUN apt-get install -y whatever ,不是吗?

Are the OS being treated as application on docker? 操作系统是否被视为docker上的应用程序?

No, there is no application concept in Docker. 不,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. Docker将提供最低的os最低版本来部署您的应用程序。 Like if you use alpine(smallest image in docker), its around 5 MB size. 就像您使用alpine(docker中最小的映像)一样,其大小约为5 MB。 You have to manually install other component specific to your application. 您必须手动安装特定于您的应用程序的其他组件。 Docker will provide you the platform to create a container. Docker将为您提供创建容器的平台。 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. 您可以使用alpine或任何高级操作系统(如ubuntu),然后即可部署应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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