Supported tags and respective
What is Clojure?
How to use this image
Start a Lein/Clojure instance in your app
Since the most common way to use Clojure is in conjunction with Leiningen (
lein), this image assumes that's how you'll be working. The most straightforward way to use this image is to add a
Dockerfile to an existing Leiningen/Clojure project:
FROM clojure COPY . /usr/src/app WORKDIR /usr/src/app CMD ["lein", "run"]
Then, run these commands to build and run the image:
docker build -t my-clojure-app . docker run -it --rm --name my-running-app my-clojure-app
While the above is the most straightforward example of a
Dockerfile, it does have some drawbacks. The
lein run command will download your dependencies, compile the project, and then run it. That's a lot of work, all of which you may not want done every time you run the image. To get around this, you can download the dependencies and compile the project ahead of time. This will significantly reduce startup time when you run your image.
FROM clojure RUN mkdir -p /usr/src/app WORKDIR /usr/src/app COPY project.clj /usr/src/app/ RUN lein deps COPY . /usr/src/app RUN mv "$(lein uberjar | sed -n 's/^Created \(.*standalone\.jar\)/\1/p')" app-standalone.jar CMD ["java", "-jar", "app-standalone.jar"]
Dockerfile this way will download the dependencies (and cache them, so they are only re-downloaded when the dependencies change) and then compile them into a standalone jar ahead of time rather than each time the image is run.
You can then build and run the image as above.
Compile your Lein/Clojure project into a jar from within the container
If you have an existing Lein/Clojure project, it's fairly straightforward to compile your project into a jar from a container:
docker run -it --rm -v "$PWD":/usr/src/app -w /usr/src/app clojure lein uberjar
This will build your project into a jar file located in your project's
View license information for the software contained in this image.
Supported Docker versions
This image is officially supported on Docker version 1.6.2.
Support for older versions (down to 1.0) is provided on a best-effort basis.
Docker, Inc is the company behind the open source Docker platform and the growing Docker ecosystem of contributors, partners and adopters revolutionizing the way distributed applications are built, shipped, and run.
Copyright (c) 2014-2015 Docker, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.