technologist, entrepreneur, vision­ary, programmer

Yes, it is now this easy to Dockerize a Play! Framework Application

| 1 Comment

Play Framework DockerizeDo you want to build a dockerized Play! Framework application to deploy on a Docker server?

Nepomuk Seiler actually tweeted about this awhile back, but I didn’t realize until today how easy it was to do.

First off make sure you already have docker  running. I am using OSX, so I used boot2docker and followed these instructions. If you don’t always read all the instructions I like do, then check out these two tips for running boot2docker on OSX:

  • make sure you set the environment variable set like: export DOCKER_HOST=tcp://
  • make sure that once the application is running you access it with the docker IP, and not localhost

Then follow the README.md instructions here: https://github.com/muuki88/sbt-native-packager-examples/tree/master/play-2.3

  1. Add the dependencies to your build.sbt
    import NativePackagerKeys._
    // setting a maintainer which is used for all packaging types</pre>
    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

    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 running, use the DOCKER_HOST IP to access it like:

I have yet to try it, but I image you can just copy the target/docker to you docker server and run it as well.

I also need to figure out how to run the the Play!Framework with different configuration files.

If you have read this far, you may as well follow me on Twitter:

Author: poornerd

Tech­nol­o­gist, Entre­pre­neur, Vision­ary, Pro­gram­mer :: Grad­u­ated from USC (Uni­ver­sity of South­ern Cal­i­for­nia) with a degree in Com­puter Sci­ence. After 10+ years of free­lance con­sult­ing and pro­gram­ming, he co-founded Site­Force AG eBusi­ness Solu­tions in 1999 in Munich (München), Ger­many.

One Comment

  1. Thanks nice article but wondering what the best way of using docker within a development workflow is:

    (1) For development want to be able to edit the code on the host e.g. in fig

    – /someplayapp

    Then have SBT running within the container pick up changes just like when you are running directly on the development machine (Think you have to turn on polling to detect changes in synchronised volumes)

    (2) For deployment want it to either freeze current contents of /someplayapp or to pull source from git

Leave a Reply

Required fields are marked *.