I've created a docker container using the following Dockerfile (truncated):
FROM ubuntu:12.04
# curl enables downloading of other things
RUN apt-get install curl -y
# download and install rvm...
RUN \curl -L https://get.rvm.io | bash -s stable
# ... so that we can install ruby
RUN /bin/bash -l -c "rvm requirements"
And so on.
This all works, but the problem I have is how / where the packages are installed.
If I just run rvm using docker run [...] rvm
I get "Unable to locate rvm", but if I run docker run [...] /bin/bash -l -c "rvm"
it works. (I found the "-l -c" options online, but have no idea what they do, and can't find a satisfactory explanation of what I'm doing!)
This isn't a docker question - it's a bash / *nix question - I presume there's something about how / where things are installed, possibly related to running the install under root?
Just to be clear - I want to be able to run the things that I install direct from the CLI.
EDIT 1
Installing Ruby using rvm is the recommended method, however if you want to run things in a non-interactive, non-login shell (i.e. within a docker container), this just causes too much hassle with paths and environment variables and login scripts not running.
Given that I am using this to run a docker container, which by definition is isolated, and recoverable (just build another one), I don't really care about switching versions, or isolating packages, and so I've decided to install Ruby from a package repo (http://brightbox.com/docs/ruby/ubuntu/) instead. This 'just works'.
It may not work for you - I am only installing Ruby in order to get the Foreman gem, as I am running an app through a Procfile, so I'm not that fussed about the details, I just need it to work. If you're building a Ruby app, I wouldn't follow my advice.
My Dockerfile is here, FWIW, https://index.docker.io/u/yunojuno/dev/
From
bash(1)
:-l
Make bash act as if it had been invoked as a login shell-c
If the -c option is present, then commands are read from string.You're running the command passed to the
-c
argument.-l
makes it a login shell so bash first reads/etc/profile
, which probably has the path torvm
which is what makes it work.FWIW, here's what I do to install
rvm
in a docker container.