2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2020

11/23/2014: Using AZUL 7 instead of OpenJDK Java for smaller Docker images.

Witness a tale of two Dockerfiles that perform the same task. See the size difference. Imagine how it might change infrastructure costs.

DOCKERFILE ONE


FROM debian:wheezy

RUN apt-get update && apt-get install -y openjdk-7-jre && rm -rf /var/lib/apt/lists/*

ADD target/si-standalone-sample-1.0-SNAPSHOT.jar /

ENV JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64
ENV CLASSPATH si-standalone-sample-1.0-SNAPSHOT.jar

CMD [ "java", "org.springframework.boot.loader.JarLauncher" ]


DOCKERFILE TWO


FROM debian:wheezy

RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0x219BD9C9 && \
  echo "deb http://repos.azulsystems.com/ubuntu precise main" >> /etc/apt/sources.list.d/zulu.list && \
  apt-get -qq update && \
  apt-get -qqy install zulu-7 && \
  rm -rf /var/lib/apt/lists/*

ADD target/si-standalone-sample-1.0-SNAPSHOT.jar /

ENV JAVA_HOME /usr/lib/jvm/zulu-7-amd64
ENV CLASSPATH si-standalone-sample-1.0-SNAPSHOT.jar

CMD [ "java", "org.springframework.boot.loader.JarLauncher" ]

Notice the only difference is which Java is being installed. Here are the image sizes:

spring-integration   openjdk  549.1 MB
spring-integration   azul     261.3 MB

That's a 288MB difference.

11/23/2014: Is using "lsb_release -cs" a good idea inside a debian:wheezy Dockerfile?

Update from Jan 2015: The Zulu team added formal Debian support last October, I just did not know about it. Look at the version history for Zulu 8.4, 7.7, and 6.6 at http://www.azulsystems.com/zulurelnotes. Also look on DockerHub for their 8.4.x Docker files. They don't use lsb_release -cs in Debian Dockerfiles anymore, and instead allow the Zulu repository to honor 'stable' as release name. 'stable' always pushes the highest level for a Java major version. - I am paraphrasing the comments from Matthew Schuetze below.

I saw the following line in a Dockerfile

RUN echo "deb http://repos.azulsystems.com/ubuntu `lsb_release -cs` main" >> /etc/apt/sources.list.d/zulu.list

The lsb_release program is not part of the wheezy standard programs. But we can install it:

$ apt-get update && apt-get install -y lsb

How many files were created by that install?

$ docker diff 09 | wc -l
30013

Over 30,000 files!

I next tried being a bit more specific with

$ apt-get update && apt-get install -y lsb-release

How many files were created by that install?

$ docker diff 23 | wc -l
1689

I conclude that hard-coding "wheezy" is better than using lsb_release in a Dockerfile. At least when using Debian as the base operating system.