Docker:如何创建堆栈,多个映像或一个基本映像? [英] Docker: How to create a stack, multiple images or one base image?

查看:77
本文介绍了Docker:如何创建堆栈,多个映像或一个基本映像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是使用Docker的新手,并且我怀疑在堆栈中使用一个映像库还是必须根据需要定义每个映像.
例如,作者阅读有关使用docker创建网站的博客时,建议使用以下堆栈:

I am new using Docker, and I got the doubt of using one image base for my stack or I have to define each image depending on my needs.
For example, reading a blog about creating a website using docker the author suggests the following Stack:

图片取自

Image taken from http://project-webdev.blogspot.de/2015/05/create-site-based-on-docker-part4-docker-container-architecture.html
Now, seen the structure, If we have base images in the Docker registry for technologies as mongoDB, io.JS, nginx, Why on this examples we do not use those images insted of using a single Docker base image for everything?

推荐答案

我是此博客文章/系列的作者,所以让我详细说明选择一个基本图像的原因. :)

I'm the author of this blog post/series, so let me elaborate on the reason why I've chosen one base image. :)

Docker提供了对后续图像使用通用基础映像的可能性,因此您可以堆叠所有映像,并且每个映像仅包含与基础映像的差异(这是docker的最大优势!).您可以节省磁盘空间和RAM.如果您对此并不在意(我的意思是RAM和存储很便宜),那么您也可以使用多张图片.

Docker offers the possibility to use a common base image for subsequent images, so you can stack all images and each image only contains the diff to the underlying image (that's the big advantage of docker!). You can save disk space and RAM. If you don't care about that (I mean RAM and storage are cheap) you can also use multiple images.

一个基本映像的另一个优点是,您可以根据需要配置/保护该基本映像.如果您对每个容器使用不同的基本映像,则必须维护所有这些映像(例如防火墙),而Docker将下载多个不同的映像(使用更多的磁盘空间,容器构建需要更长的时间).

Another advantage of one base image is that you can configure/secure that base image based on your needs. If you use a different base image for each container, you have to maintain all of them (e.g. firewall) and Docker will download several different images (uses more disk space, container builds take longer)).

但是,当您查看官方图像时有什么区别?官方的mongodb,redis和MySQL映像均基于debian:wheezy映像.因此,如果您使用这些图像,它们也将基于相同的基本图像,不是吗?

But what's the difference when you look at the official images? The official mongodb, redis and MySQL images are based on the debian:wheezy image. So if you use these images, they will also be based on the same base image, won't they?

无论如何,如果您想使用自己的架构,请放心...请将此架构/博客文章视为创建Docker设置的可能想法.多亏了Docker,并且它们共享内核的方式,您可以使用任意数量的映像. :)

Anyway, if you want to use your own architecture, feel free... please consider this architecture/blog post as possible idea of creating a Docker setup. Thanks to Docker and they way it shares the kernel, you can use as many images you want. :)

此致

Sascha

这篇关于Docker:如何创建堆栈,多个映像或一个基本映像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆