简体   繁体   中英

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 .

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. 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.

Is this done on purpose?

Is it a bad practice to use version managers for programming languages inside docker containers?

Why?

This would be considered a bad practice or anti-pattern in docker. RVM is trying to solve a similar problem that docker is solving, but with a very different approach. RVM is designed for a host or VM with all the tools installed in one place. Docker creates an isolated environment where only the tools you need to run your single application are included.

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).

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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