Search code examples
scaladockersbt-native-packager

Can not reach HTTP servlet when built as Dockercontainer


Hello and thanks for taking time :)

Currently I am facing some Problems with sbt-native-packager and Docker. I'm relatively new to this. Actually, its my first try. And here comes my problem: I've got an Actor, that should respond to HTTP requests. It works fine if I run it native without Docker. Now I want it to be built as an Dockercontainer (there are serveral companions so I use docker compose). Therefore, I use sbt-native-packager but now when I hit localhost:4444 I just get "Not found". So I think there's something wrong with my dockerBuild Settings. I just can't find out what :(

Here some code:

Settings

lazy val graphiteprocSetting = eventprocSettings ++ Seq(
name := "graphite-processor",
dockerBaseImage := "nimmis/java:oracle-8-jdk",
daemonUser in Docker := "root",
debianChangelog in Debian := Some(file("*")),
mainClass in Compile := Some("*.StreamProcessorKafkaToGraphite"))

Build

 lazy val graphiteproc =  Project(                                                                          
    id = "graphiteproc",                                                                                     
    base = file("modules/graphiteproc"),                                                                     
    settings = graphiteprocSetting                               
  ).enablePlugins(DebianPlugin, JavaServerAppPackaging, DebianDeployPlugin, DockerPlugin, BuildInfoPlugin)   

Docker-compose.yml

graphiteprocessor:
  # TODO insert correct version via sbt
  image: graphite-processor:0.1.13-SNAPSHOT
  volumes:
    - ./conf:*
  environment:
    JAVA_OPTS: "-Dconfig.file=*"
  ports:
    - "4444:4444"
  links:
      - graphite
      - kafka

output of docker inspect:

"NetworkSettings": {
        ...
        "Ports": {
            "4444/tcp": [
                {
                    "HostIp": "0.0.0.0",
                    "HostPort": "4444"
                }
            ]
        },
        ...
        "Gateway": "172.17.0.1",
        ...
        "IPAddress": "172.17.0.2",
        "Networks": {
            "bridge": {
                ...
                "Gateway": "172.17.0.1",
                "IPAddress": "172.17.0.2",
                ...

            }
        }
    }

Solution

  • using 0.0.0.0 as host and changing the base image to gdepuille/fedora-java worked for me.