使用Docker容器应该避免的10个事情
So you finally surrendered to containers and discovered that it solves a lot of problems and has a lot of advantages:
1.First: It’s immutable – The, OS, Library versions, configurations, folders, application is there. You guarantee that the same image tested in QA will arrive land in the production with the same behaviour.
莫让年华付水流2.Second: It’s lightweight – The memory footprint of a container is too small. Instead of hundreds or thousands of MBs, it will just allocate the memory for the main process plus some tens of MBs.
3.Third: It’s fast – You can start a container as fast as a single process takes to start. Instead of minutes, you can start a new container in at most some few conds.
译者信息
译者信息
社会主义好
翻译于 1年前
1人 顶 此译文
当你最后投入容器的怀抱,发现它能解决很多问题,而且还具有众多的优点:
1.第一:它是不可变的 – 操作系统,库版本,配置,文件夹和应用都是一样的。您可以使用通过相同QA测试的镜像,使产品具有相同的表现。
2.第二:它是轻量级的 – 容器的内存占用非常小。不需要几百几千MB,它只要对主进程分配内存再加上几十MB。
3.第三:它很快速 – 启动一个容器与启动一个单进程一样快。不需要几分钟,您可以在几秒钟内启动一个全新的容器。
自然观察But many urs still treating containers just like typical virtual machines and forget that they also have another great advantage besides many others: It’s disposable.
The big mantra about containers:
“Containers are ephemeral”.
This characteristic “per ” forces urs to change their mindt on how they should handle and manage containers; and I’ll explain what you should NOT do in containers to keep extracting the best benefits of it:
译者信息
译者信息
社会主义好
翻译于 1年前
2两级传播人 顶 此译文
但是,许多用户依然像对待典型的虚拟机那样对待容器。但是他们都忘记了除了与虚拟机相似的部分,容器还有一个很大的优点:它是一次性的。
容器的 春联精选准则 :
“容器是临时的”。
这个特性“本身”促使用户改变他们关于使用和管理容器的习惯;我将会向您解释在容器中不应该做这些事,以确保最大地发挥容器的作用。
1) Don’t store data in containers – A container can be stopped, destroyed, or replaced. An application version 1.0 running in container should be easily replaced by the version 1.1 without any impact or loss of data. For that reason, if you need to store data, store it in a volume, but take care if two containers write data on the same volume becau it could cau corruption. Make sure your applications are designed to write to shared data stores.
2) Don’t ship your application in two pieces – As some people e containers as a virtual machine. Most of them tend to think that they should deploy their application in existing running containers. That can be true during thedevelopment pha where you ne
ed to deploy and debug continuously; but for a continuous deployment (cd) pipeline in QA and production, your application should be part of the image. Remember: Containers should beimmutable.
译者信息
译者信息
莫家拳skyvoice7
翻译于 1年前
3啤酒品牌人 顶 此译文
其它翻译版本:1(点击译者名切换)
社会主义好
1) 不要在容器中存储数据 – 容器可能被停止,销毁,或替换。一个运行在容器中的程序版
本1.0,应该很容易被1.1的版本替换且不影响或损失数据。有鉴于此,如果你需要存储数据,请存在卷中,并且注意如果两个容器在同一个卷上写数据会导致崩溃。确保你的应用被设计成在共享数据存储上写入。
2) 不要将你的应用发布两份 – 一些人将容器视为虚拟机。他们中的大多数倾向于认为他们应该在现有的运行容器里发布自己的应用。在开发阶段这样是对的,此时你需要不断地部署与调试;但对于质量保证与生产中的一个连续部署的管道,你的应用本该成为镜像的一部分。记住:容器应该保持不变。
译者信息
译者信息
社会主义好
翻译于 1年前
0人 顶 此译文
其它翻译版本:1(点击译者名切换)
skyvoice7
1) 不要在容器中存储数据。– 容器可能被停止,销毁或者替换。运行在容器中的应用,使用1.1版替换1.0版时应该不影响或丢失任何数据。鉴于此,如果您需要存储数据,请将数据存储在一个卷中,但是,请注意,如果两个容器对相同的卷写数据,应避免冲突。请确保您的应用可以共享数据存储。
2) 不要将您的应用分成两部分– 由于一些人将容器当作虚拟机,他们中的大多数人倾向于认为应该将应用部署在正运行的容器中。这样做在开发状态等您需要连续部署和调试的情况下是可以的;但是,对于QA和中国城市人口排名产品部署中,您的应用应该是镜像的一部分。记住:容器应该是不可变的。
3) Don’t create large images – A large image will only make it hard to distribute. Make sure that you have only the required files and libraries to run your application/process. Don’t install unnecessary packages or run “updates”(yum update) during builds.
4) Don’t u a single layer image – To have a more rational u of the layered filesystem, always create your own ba image layer for your OS, another layer for the curity and ur definition, another layer for the lib installation, another layer for the configuration, and finally another layer for the application. It will be easy to recreate and manage an image, and easy to distribute.
5) Don’t create images from running containers – In other terms, don’t u “docker commit” to create an image. This way to build an image is not reproducible and it’s not versionable, and should be completely avoided. Always u a Dockerfile or any other S2I (source-to-image) approach that is totally reproducible.
译者信息
译者信息
skyvoice7
翻译于 1年前
2人 顶 此译文
3) 不要创建超大镜像 – 一个超大镜像只会难以分发。确保你仅有运行你应用/进程的必需的文件和库。不要安装不必要的包或在创建中运行更新(yum更新)。
4) 不要使用单层镜像 – 要对分层文件系统有更合理的使用,始终为你的操作系统创建你自己的基础镜像层,另外一层为安全和用户定义,一层为库的安装,一层为配置,最后一层为应用。这将易于重建和管理一个镜像,也易于分发。
5) 不要为运行中的容器创建镜像 – 换言之,不要使用“docker commit”命令来创建镜像。这种创建镜像的方法是不可重现的也不能版本化,应该彻底避免。始终使用Dockerfile或任何其他的可完全重现的S2I(源至镜像)方法。
6) Don’t u only the “latest” tag 观音送福– The latest tag is just like the “SNAPSHOT” for Maven urs. Tags are encouraged to be ud specially when you have a layered filesytem. You don’t want to have surpris when you build your image 2 months later and figure out that your application can’t run becau a top layer was replaced by a new
version that it’s not backward compatible or becau a wrong “latest” version is in the build cache. The latest should also be avoided when deploying containers in production.