简体   繁体   English

在Docker容器中使用像RVM这样的版本管理器是不好的做法吗?

[英]Is it a bad practice to use version managers like RVM inside docker containers?

I'm new to using docker and so far I'm unable to find many ruby/rails images that contain RVM or rbenv . 我是使用rbenv ,到目前为止,我无法找到包含RVMrbenv许多ruby / rails图像。

The most common thing I see is that each container has multiple tags and each tagged image version has only one version of Ruby installed. 我看到的最常见的事情是每个容器都有多个标签 ,每个标记的图像版本安装了一个 Ruby版本。 See this image for example. 例如,请参见此图片

The only way to use another version is to use another tag for the image you are using as you can not install a new version with RVM nor with rbenv. 使用其他版本的唯一方法是为您正在使用的映像使用另一个标记,因为您无法使用RVM或rbenv安装新版本。

Is this done on purpose? 这是故意的吗?

Is it a bad practice to use version managers for programming languages inside docker containers? 在docker容器中使用版本管理器编程语言是不好的做法吗?

Why? 为什么?

This would be considered a bad practice or anti-pattern in docker. 这在docker中被认为是一种不好的做法或反模式。 RVM is trying to solve a similar problem that docker is solving, but with a very different approach. RVM正在尝试解决docker正在解决的类似问题,但采用了一种截然不同的方法。 RVM is designed for a host or VM with all the tools installed in one place. RVM专为主机或VM而设计,所有工具都安装在一个位置。 Docker creates an isolated environment where only the tools you need to run your single application are included. Docker创建了一个隔离的环境,其中只包含运行单个应用程序所需的工具。

Containers are ideally minimalistic, only containing the prerequisites needed for your application, making them more portable. 容器理想上是简约的,只包含应用程序所需的先决条件,使它们更具可移植性。 Docker also uses layers and a union filesystem to reuse common base images for each image, so any copy of something like Ruby version X is only downloaded and written to disk once, ever (ignoring updates to that image). Docker还使用层和联合文件系统来重用每个映像的公共基础映像,因此任何类似Ruby版本X的副本只会下载并写入磁盘一次(忽略对该映像的更新)。

It depends on how you are going to use it. 这取决于你将如何使用它。 If you need to install about any version of ruby on the custom docker image without messing around with downloading tarballs and applying patches RVM can be just perfect. 如果你需要在自定义docker镜像上安装任何版本的ruby,而不必担心下载tarball和应用补丁RVM可能是完美的。 RVM is basically a bash script so using it inside of docker container is as bad as using any other bash script inside of docker container. RVM基本上是一个bash脚本,因此在docker容器中使用它与在docker容器中使用任何其他bash脚本一样糟糕。

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

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