I'm setting up a docker image, I've managed to get it working, but only by running one long RUN command with everything in it.
I want to break it into smaller RUN commands for ease of maintenance and debugging, etc.
My first RUN command looks like this:
RUN apt-get update --quiet && \
apt-get install --quiet --yes --no-install-recommends \
build-essential \
libssl-dev \
zlib1g-dev \
libreadline-dev \
libffi-dev \
libyaml-dev && \
git clone --depth 1 https://github.com/rbenv/rbenv.git ~/.rbenv && \
git clone --depth 1 https://github.com/rbenv/ruby-build.git && \
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc && \
echo 'eval "$(rbenv init -)"' >> ~/.bashrc && \
/bin/bash -c "source ~/.bashrc"
When I try call the rbenv install script in the next RUN command docker can't find it. Why is this? I've tried adding the path in the new RUN command, but it doesn't seem to make a difference.
What am I doing wrong?
rbenvin Docker, but they're also rarely necessary since a typical image contains a single application and its single specific language runtime. Can you build your DockerfileFROMthe correct version of therubyimage, and delete this setup entirely?FROMline, anddocker build --build-argto pass it in. See Understand how ARG and FROM interact in the Dockerfile reference.