TheJF
TheJF

Reputation: 841

Using rbenv with Docker

I am trying to setup rbenv with a Dockerfile, but this just fails on rbenv install. I do have ruby-build in there, it just doesn't seem to work.

Relevant bits of the Dockerfile (largely lifted from https://gist.github.com/deepak/5925003):

# Install rbenv
RUN git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv
RUN echo '# rbenv setup' > /etc/profile.d/rbenv.sh
RUN echo 'export RBENV_ROOT=/usr/local/rbenv' >> /etc/profile.d/rbenv.sh
RUN echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/profile.d/rbenv.sh
RUN echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh
RUN chmod +x /etc/profile.d/rbenv.sh

# install ruby-build
RUN mkdir /usr/local/rbenv/plugins
RUN git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build

ENV PATH /usr/local/rbenv/shims:/usr/local/rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

# Set to Ruby 2.0.0-p247
RUN rbenv install 2.0.0-p247
RUN rbenv rehash
RUN rbenv local 2.0.0-p247

Error:

Step 21 : RUN rbenv install 2.0.0-p247
 ---> Running in 8869fa8f0651
rbenv: no such command `install'
Error build: The command [/bin/sh -c rbenv install 2.0.0-p247] returned a non-zero code: 1
The command [/bin/sh -c rbenv install 2.0.0-p247] returned a non-zero code: 1

Upvotes: 9

Views: 9373

Answers (2)

Flair
Flair

Reputation: 2907

If you only need one Ruby version, just use the official Ruby images: https://hub.docker.com/_/ruby

Upvotes: 1

Till
Till

Reputation: 22408

You're missing a setup step for ruby-build: You need to run its install.sh after you cloned it.

Upvotes: 7

Related Questions