1

I am using Marathon to deploy my Docker containerised node.js application. My Marathon app spec is as follows :

 {
  "id": "<some-name>",
  "cmd": null,
  "cpus": 1,
  "mem": 2800,
  "disk": 30720,
  "instances": 1,
  "container": {
    "docker": {
      "image": "<some-docker-registry-IP>:5000/<repo>",
      "network": "BRIDGE",
      "privileged": true,
      "forcePullImage": true,
      "parameters": [
        {
          "key": "net",
          "value": "host"
        }
      ],
      "portMappings": [
        {
          "containerPort": <some-port>,
          "hostPort": <some-port>,
          "protocol": "tcp",
          "name": null
        }
      ]
    },
    "type": "DOCKER"
  }
}

The problem however is that this leads to restarting my server where application is deployed once it is out of memory. I need my services to listen on private IP of host machine and that's why I am using --net=host.

Is it possible to just kill the task freeing up the memory so that Marathon can re-spawn it without restarting/shutting down server? Or is there any other way to make the Docker container routable to the outside world without using --net=host?

Michael Hausenblas
  • 13,162
  • 4
  • 52
  • 66
t6nand
  • 710
  • 1
  • 8
  • 20

1 Answers1

1

Basically, I think there is a problem with you Node application if it shows a memory leaking behavior. Thats the first point I'd address.

Second one is that you should use something like pm2 in your application's Docker image which will take care of restarting you application (in the container itself) when it encounters a problem.

Furthermore, you could implement a Marathon health endpoint, so that Marathon can recognize that the application actually has problems.

To reach some redundancy, I'd strongly advise that you run at least two instances of the application, and use Mesos DNS and a load balancer like marathon-lb on the public slave node(s), which will take care of the routing. This also allows you to use bridged networking if you want to.

Tobi
  • 31,405
  • 8
  • 58
  • 90