I have a very simple Akka-http application, which is basically not much more than setting up Hello-world. I defined the endpoint and simply bound it to "localhost" and port "8080":
object Main extends App with Routes {
private implicit val system = ActorSystem()
protected implicit val executor: ExecutionContext = system.dispatcher
protected implicit val materializer: ActorMaterializer = ActorMaterializer()
protected val log: LoggingAdapter = Logging( system, getClass )
log.info( "starting server" )
Http().bindAndHandle( logRequestResult("log",Logging.InfoLevel)( allRoutes ), "localhost", 8080 )
log.info( "server started, awaiting requests.." )
}
(allRoutes mixes through Routes, but is just a dummy endpoint that serializes a simple case class for a JSON response)
If I ran it using sbt, then the endpoints work fine ( http: // localhost: 8080 / color / red ).
Now I'm trying to pack it in a Docker container to run it - I read things like http://yeghishe.imtqy.com/2015/06/24/running-akka-applications.html and added sbt -native-package plugin ( http://www.scala-sbt.org/sbt-native-packager/formats/docker.html#customize ).
Now i run sbt docker:publishLocal
And I see that the docker image was created:
REPOSITORY TAG IMAGE ID CREATED SIZE
sample-rest-api 0.0.1 3c6ee44985b4 9 hours ago 714.4 MB
If I now run my image by mapping port 8080 as follows:
docker run -p 8080:8080 sample-rest-api:0.0.1
I see the log output that I usually see at startup, so it looks like it started fine, however, if I then try to access the same URL as before, I now get the answer
"Problem loading page: connection was reset"
docker ps, , , :
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
27848729a425 sample-rest-api:0.0.1 "bin/sample-rest-api" About a minute ago Up About a minute 0.0.0.0:8080->8080/tcp furious_heisenberg
Ubuntu 16.04 - ?