---
title: "Yes, it is now this easy to Dockerize a Play! Framework Application"
date: 2014-10-10T12:01:44+00:00
author: "poornerd"
tags: ["Docker", "PlayFramework"]
canonical: https://www.poornerd.com/2014/10/10/yes-it-is-now-this-easy-to-dockerize-a-play-framework-application/
source: Raw Markdown twin of the HTML article; content is the original source.
---
[<img src="https://www.poornerd.com/wp-content/uploads/2014/10/Screen-Shot-2014-10-10-at-13.40.47-300x249.png" alt="Play Framework Dockerize" width="300" height="249" class="alignleft size-medium wp-image-463" srcset="https://www.poornerd.com/wp-content/uploads/2014/10/Screen-Shot-2014-10-10-at-13.40.47-300x249.png 300w, https://www.poornerd.com/wp-content/uploads/2014/10/Screen-Shot-2014-10-10-at-13.40.47.png 999w" sizes="(max-width: 300px) 100vw, 300px" />](https://www.poornerd.com/wp-content/uploads/2014/10/Screen-Shot-2014-10-10-at-13.40.47.png)Do you want to build a dockerized Play! Framework application to deploy on a Docker server?

<a href="https://github.com/muuki88" onclick="javascript:pageTracker._trackPageview('/outbound/article/github.com');" target="_blank">Nepomuk Seiler</a> actually tweeted about this awhile back, but I didn&#8217;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 <a href="http://boot2docker.io/" onclick="javascript:pageTracker._trackPageview('/outbound/article/boot2docker.io');" target="_blank">boot2docker</a> and followed these <a href="https://docs.docker.com/installation/mac/" onclick="javascript:pageTracker._trackPageview('/outbound/article/docs.docker.com');" target="_blank">instructions</a>. If you don&#8217;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://192.168.59.103:2375
  * make sure that once the application is running you access it with the docker IP, and not localhost

Then follow the <a href="https://github.com/muuki88/sbt-native-packager-examples/tree/master/play-2.3" onclick="javascript:pageTracker._trackPageview('/outbound/article/github.com');" target="_blank">README.md</a> instructions here: <a href="https://github.com/muuki88/sbt-native-packager-examples/tree/master/play-2.3" onclick="javascript:pageTracker._trackPageview('/outbound/article/github.com');" target="_blank">https://github.com/muuki88/sbt-native-packager-examples/tree/master/play-2.3</a>

  1. Add the dependencies to your build.sbt <pre class="brush: plain; title: ; notranslate" title="">import NativePackagerKeys._

....

// setting a maintainer which is used for all packaging types&lt;/pre&gt;
maintainer:= "Your Name"

// exposing the play ports
dockerExposedPorts in Docker := Seq(9000, 9443)

// run this with: docker run -p 9000:9000 &lt;name&gt;:&lt;version&gt;
</pre>

  2. Then build it: <pre class="brush: plain; title: ; notranslate" title="">sbt docker:publishLocal</pre>

  3. <pre></pre>
    
    Then run it! (replace the &#8220;play-2-3&#8221; with your name from the build.sbt, and the &#8220;1.0-SNAPSHOT&#8221; with your version)
    
    <pre class="brush: plain; title: ; notranslate" title="">docker run -p 9000:9000 play-2-3:1.0-SNAPSHOT</pre>

Once it is running, use the DOCKER_HOST IP to access it like: http://192.168.59.103:9000

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.
