Building Play App as Docker image, remapping port

I’m trying to build my Play application into a docker container thats exposed on port 8080. ie. Requests to the docker container on port 8080 hit my play application.

I’m having trouble doing this. I was thinking I could do it by either mapping Docker port 8080 to the internal port 9000, but I can’t figure out how to do this with the sbt plugin. All I can do is change the exposed port using

  • Gitlab-runner local build - login from non TTY device
  • How can I use Docker to run my all selenium test cases on all instance of my application using a single machine?
  • Docker multiple entrypoints
  • How to write files from Docker image to EFS?
  • Deploying multicontainer docker environment (flask & nginx) with EBS
  • Cannot connect to localhost with Rocketchat on Docker
  • dockerExposedPorts := Seq(8080)

  • How to configure the docker file to run cgi-script like perl
  • Docker fails to start due to “volume store metadata database: timeout”
  • Installing cPhalcon on AWS Docker Image
  • Kubernetes: Unable to create repository
  • Docker container on another IP and not reachable
  • Docker Containers not running on boot2docker boot
  • 2 Solutions collect form web for “Building Play App as Docker image, remapping port”

    sbt-docker only builds the docker image. Exposing a port is correct, but you still have to connect it to the host network.

    For that you have to start the container and provide the correct mapping.

    docker run -p 9000:8080 ... yourImage ...

    You have two options. First one is to start the play app with the default port 9000 and when running your container use Docker port mapping to redirect from port 8080 outside of the container to port 9000 inside of the container:

    docker run -p 8080:9000 yourimage

    Option two is to to edit your application.conf and change the production port to be 8080:

    # production
    play.server.http.port = "8080"

    after having done it, change the dockerExposedPorts:

    dockerExposedPorts := Seq(8080)

    Note, that it will still run on port 9000 in the development mode (activator run).

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.