简体   繁体   English

为什么我们只能将图像推送而不将docker-compose.yml推送到dockerhub

[英]Why can we only push images and no docker-compose.yml to dockerhub

Why can we only put images on Docker hub and no docker-compose files. 为什么我们只能将映像放在Docker Hub上,而没有docker-compose文件。 I mean there are a lot of applications using multiple containers which might be reusable, maybe with slight configurations. 我的意思是,有许多使用多个容器的应用程序可能是可重用的,也许只需进行一些配置即可。

Or is there a way to do exactly that? 还是有办法做到这一点? For now I use Docker hub for my images and a git repository for the compose files. 现在,我将Docker Hub用于图像,并将git存储库用于撰写文件。 However I feel like it would be nicer to have only one place to store all this. 但是我觉得只有一个地方存储所有这些会更好。

So the question is, can one store docker-compose files the way one stores images? 因此,问题是,是否可以像存储映像那样存储docker-compose文件? If no, is there an explanation to why the people at Docker think it is a bad idea? 如果不是,是否有解释为什么Docker的人们认为这是一个坏主意? Finally, is there a library of docker-compose files? 最后,是否有一个docker-compose文件库? I mean one finds images on docker hub in a high quality but the docker-compose files I found where on github and not very reliable. 我的意思是人们可以在docker hub上找到高质量的图像,但是我在github上找到的docker-compose文件并不十分可靠。

Short answer: I believe this would be seen as a security vulnerability. 简短的回答:我认为这将被视为安全漏洞。

A registry server stores images, and Docker Hub is just an implementation of a registry server. 注册表服务器存储映像,而Docker Hub只是注册表服务器的一种实现。 The docker-compose.yml file is a definition of how to run the image. docker-compose.yml文件是如何运行映像的定义。 How to run that image includes things like volume mounts, ports to publish, namespaces to disable, each of which are a potential to inject a security vulnerability. 如何运行该映像包括诸如卷挂载,要发布的端口,要禁用的命名空间之类的事情,每一项都有可能注入安全漏洞。 If instead of running an image with secure defaults, you were to run a remote compose file with unknown security settings, with a file hosted by docker, you would be opening yourself up to an easy remote attack vector that would likely be associated with docker rather than the private repo owner. 如果不是运行带有安全默认值的映像,而是运行带有未知安全设置的远程撰写文件,并使用由docker托管的文件,则将自己暴露给一个可能与docker关联的简单远程攻击媒介,比私人回购所有者。 So with Docker's high priority to security, I doubt you'll see this hosted by them. 因此,鉴于Docker对安全性的高度重视,我怀疑您会看到它们由他们托管。

The standard approach where you include a Dockerfile and docker-compose.yml in a github repo is the traditional single location for everything. 在github存储库中包含Dockerfile和docker-compose.yml的标准方法是所有内容的传统单一位置。 The docker hub registry becomes a prebuilt cache for the image. docker hub注册表将成为映像的预构建缓存。 That can be recreated using the compose file to define the build options, and the Dockerfile with the rest of the repo to define everything needed to create the image. 可以使用compose文件定义构建选项,并使用Dockerfile和其余的repo来重新创建,以定义创建映像所需的所有内容。 In fact, the docker build command allows you to point directly to a public github repo instead of requiring you to first clone it locally. 实际上, docker build命令允许您直接指向公共github存储库,而无需先在本地克隆它。

In theory, one can store Docker-compose files & Dockerfiles in source control, so something like github. 从理论上讲,可以将Docker组成的文件和Dockerfiles存储在源代码控制中,例如github。

The reason images are preferred, and why there is a Docker hub, is because the image is the unit that bundles together the app and the environment - which is what helps ensure that the app will run the same way wherever. 首选映像的原因以及拥有Docker集线器的原因是因为映像是将应用程序和环境捆绑在一起的单元-这有助于确保应用程序在任何地方都能以相同的方式运行。

Dockerfiles are the instructions to build images, and they do so with limitations; Dockerfile是构建映像的指令,但这样做有局限性。 from a given image, one can only make so many modifications (see answer here: Number of commands in Dockerfile ). 从给定的映像中,只能进行这么多修改(请参阅此处的答案: Dockerfile中的命令数 )。

There is not as strong a guarantee that someone else can build an image from a Dockerfile/docker-compose script that will behave the same - dependencies could be different, packages changing, etc. A docker image should be stand alone, testable, and will most likely run the same in successive uses ( not guaranteed, but usually). 并不能完全保证其他人可以从Dockerfile / docker-compose脚本中构建具有相同行为的映像-依赖关系可能有所不同,程序包发生更改等。Docker映像应该是独立的,可测试的,并且会最有可能在连续使用中以相同的方式运行( 保证,但通常)。

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

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