Skip to content

Instantly share code, notes, and snippets.

@malovme
Created April 13, 2018 18:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malovme/ad28917f1d86fac20b9c2634fbd0a048 to your computer and use it in GitHub Desktop.
Save malovme/ad28917f1d86fac20b9c2634fbd0a048 to your computer and use it in GitHub Desktop.
Dockerfile to build image with ruby via rvm on ubuntu
FROM ubuntu:16.04
# Using rvm inside docker is bad practice (docker anti-pattern) https://stackoverflow.com/a/41925488/3292174
RUN apt-get update && apt-get install -y openssl curl
# rvm
RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
RUN \curl -L https://get.rvm.io | bash -s stable
# ruby
RUN bash -c -l 'rvm install ruby-x.x.x'
# bundler
RUN bash -c -l 'gem install bundler --no-ri --no-rdoc'
# You can build docker image with:
# `cd /path/to/this/Dockerfile`
# `docker build -t rvm_ruby .`
# Start docker container with interactive bash:
# `docker run -it rvm_ruby bash`
# Inside container:
# `bash -l`
# `ruby -e "puts RUBY_VERSION"`
@aranderia15
Copy link

what does -l and -c command stands for?

@zachbugay
Copy link

You can read more here
This is the equivalent to executing bash to login, and then reading the following string as an execution to perform within bash.

bash -c -l 'rvm install ruby-x.x.x'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment