When an author builds the image https://github.com/cpuguy83/docker-jruby/blob/10eae9359611104c013e82206104b40f20fac377/1.7/Dockerfile:
FROM java:8
ENV JRUBY_VERSION 1.7.16
RUN mkdir /opt/jruby \
&& curl http://jruby.org.s3.amazonaws.com/downloads/${JRUBY_VERSION}/jruby-bin-${JRUBY_VERSION}.tar.gz \
| tar -zxC /opt/jruby --strip-components=1 \
&& update-alternatives --install /usr/local/bin/ruby ruby /opt/jruby/bin/jruby 1
ENV PATH /opt/jruby/bin:$PATH
RUN echo 'gem: --no-rdoc --no-ri' >> /.gemrc
RUN gem install bundler
CMD [ "irb" ]
…they tag it with (for example) 1.7.16
so that the other docker image https://github.com/cpuguy83/docker-jruby/blob/10eae9359611104c013e82206104b40f20fac377/1.7/onbuild/Dockerfile:
FROM jruby:1.7.16
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
ONBUILD ADD Gemfile /usr/src/app/
ONBUILD ADD Gemfile.lock /usr/src/app/
ONBUILD RUN bundle install --system
ONBUILD ADD . /usr/src/app
…can then build from that (e.g. FROM jruby:1.7.16
).
Then when that image is pushed up they tag it 1.7-onbuild
(as they utilise the ONBUILD
feature).
We then base our own Docker image off of FROM jruby:1.7-onbuild
. Using jruby:1.7-onbuild
means when we build our own image the gems are already installed, and it avoids the issue of installing the Gems every time you execute docker run
an image to start up a container.