Official Docker image for Clojure
This is the repository for the official Docker image for Clojure. It is automatically pulled and built by Stackbrew into the Docker registry. This image runs on OpenJDK 8, 11, 14, 15, and 16 and includes Leiningen, boot, and/or tools-deps (see below for tags and building instructions).
The version tags on these images look like
(openjdk-major-version-)lein-N.N.N(-distro),
(openjdk-major-version-)boot-N.N.N(-distro), and
(openjdk-major-version-)tools-deps(-distro). These refer to which version of leiningen, boot, or tools-deps is packaged in the image (because they can then install and use any version of Clojure at runtime). The
lein(or
lein-slim-buster,
openjdk-14-lein, etc.) images will always have a recent version of leiningen installed. If you want boot, specify either
clojure:boot,
clojure:boot-slim-buster, or
clojure:boot-N.N.N,
clojure:boot-N.N.N-slim-buster,
clojure:openjdk-14-boot-N.N.N-slim-buster, etc. (where
N.N.Nis the version of boot you want installed). If you want to use tools-deps, specify either
clojure:tools-deps,
clojure:tools-deps-slim-busteror other similar variants.
As of 2020-3-20 the
clojure:latest(also
clojurebecause
latestis the default) now has leiningen, boot, and tools-deps installed.
Previously this tag only had leiningen installed. Installing the others is helpful for quick start examples, newcomers, etc. as leiningen is by no means the de facto standard build tool these days. The downside is that the image is larger. But for the
latesttag it's a good trade off because for anything real we have always recommended using more specific tags. No other tags are affected by this change.
Java has recently introduced a new release cadence of every 6 months and dropped the leading
1major version number. As of 2019-9-25, our images will default to the latest LTS release of OpenJDK (currently 11). But we also now provide the ability to specify which version of Java you'd like via Docker tags:
JDK 1.8 tools-deps image:
clojure:openjdk-8-tools-depsJDK 11 variant of that image:
clojure:openjdk-11-tools-depsor
clojure:tool-depsJDK 14 with the latest release of leiningen:
clojure:openjdk-14JDK 15 with boot 2.8.3:
clojure:openjdk-15-boot-2.8.3
The upstream OpenJDK images are built on a few different variants of Debian Linux, so we have exposed those in our Docker tags as well. The default is now Debian slim-buster. But you can also specify which distro you'd like by appending it to the end of your Docker tag as in the following examples (but note that not every combination is provided upstream and thus likewise for us):
JDK 1.8 leiningen on Debian slim-buster:
clojure:openjdk-8or
clojure:openjdk-8-leinor
clojure:openjdk-8-lein-stretchJDK 1.8 leiningen on Debian buster:
clojure:openjdk-8-busteror
clojure:openjdk-8-lein-busterJDK 11 tools-deps on Debian slim-buster:
clojure:tools-depsor
clojure:openjdk-11-tools-depsor
clojure:openjdk-11-tools-deps-slim-busterJDK 15 tools-deps on Alpine:
clojure:openjdk-15-tools-deps-alpine
Most of the upstream alpine-based openjdk builds have been deprecated, so we have followed suit. As of 2020-8-14 we provide an alpine variant for OpenJDK 16 builds, but that's it. And it is likely that that build will go away once OpenJDK 17 is released (as has happened with other recent releases).
For other versions of OpenJDK, we recommend migrating to the
slim-bustervariant instead. The older
alpineimages won't go away, but neither will they receive security updates, version bumps, etc. We recommend that you cease using them until / unless official upstream support resumes.
clojure:slim-buster
These images are based on the Debian buster distribution but have fewer packages installed and are thus much smaller than the
stretchor
busterimages. Their use is recommended.
Run an interactive shell from this image.
docker run -i -t clojure /bin/bash
Then within the shell, create a new Leiningen project and start a Clojure REPL.
lein new hello-world cd hello-world lein repl
The Dockerfiles are generated by the
docker-clojureClojure app in this repo.
You'll need the
tools-depsdistribution of Clojure installed to run the build. Often this just means installing the
clojurepackage for your system.
The
./build-images.shscript will generate the Dockerfiles and build all of the images.
The
docker-clojurebuild tool has a test suite that can be run via the
./test.shscript.