It is now this easy to Dockerize a Play! Framework Application

Do you want to build a dock­er­ized Play! Frame­work appli­ca­tion to deploy on a Docker server?

Nepo­muk Seiler actu­ally tweeted about this awhile back, but I didn’t real­ize until today how easy it was to do.

First off make sure you already have docker run­ning. I am using OSX, so I used boot2docker and fol­lowed these instruc­tions. If you don’t always read all the instruc­tions I like do, then check out these two tips for run­ning boot2docker on OSX:

  • make sure you set the envi­ron­ment vari­able set like: export DOCKER_HOST=tcp://
  • make sure that once the appli­ca­tion is run­ning you access it with the docker IP, and not localhost

Then fol­low the README​.md instruc­tions here: https://​github​.com/​m​u​u​k​i​8​8​/​s​b​t​-​n​a​t​i​v​e​-​p​a​c​k​a​g​e​r​-​e​x​a​m​p​l​e​s​/​t​r​e​e​/​m​a​s​t​e​r​/​p​l​a​y​-​2.3

  1. Add the depen­den­cies to your build.sbt
import NativePackagerKeys._
// setting a maintainer which is used for all packaging types
maintainer:= “Your Name”
// exposing the play ports
dockerExposedPorts in Docker := Seq(9000, 9443)
// run this with: docker run -p 9000:9000 <name>:<version>

2. Then build it

sbt docker:publishLocal

3. Then run it! (replace the “play-2–3″ with your name from the build.sbt, and the “1.0-SNAPSHOT” with your version)

docker run -p 9000:9000 play-2–3:1.0-SNAPSHOT

Once it is run­ning, use the DOCKER_HOST IP to access it like:

There you go, the next step is to figure out how to run the the Play!Framework with dif­fer­ent con­fig­u­ra­tion files.