Skip to content
Brenden Matthews edited this page Jul 12, 2016 · 1 revision

Can I use MLB with Docker in host networking mode?

Yes, of course! Most of the examples and documentation only show examples with Docker bridge networking (NAT) enabled. This is merely because it's more convenient. Here's a sample Python HTTP server which uses host networking, binding to $PORT0, and exposing the service on port 10010:

{
  "id": "/http-derp-pants-python",
  "cmd": "python -m http.server $PORT0",
  "cpus": 0.1,
  "mem": 32,
  "instances": 2,
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "python:3",
      "network": "HOST"
    }
  },
  "healthChecks": [
    {
      "path": "/",
      "protocol": "HTTP",
      "portIndex": 0,
      "gracePeriodSeconds": 30,
      "intervalSeconds": 6,
      "timeoutSeconds": 2,
      "maxConsecutiveFailures": 3
    }
  ],
  "labels": {
    "HAPROXY_GROUP": "external"
  },
  "portDefinitions": [
    {
      "port": 10010,
      "protocol": "tcp"
    }
  ]
}

For more details on port handling in Marathon, check the Marathon documentation.

Can I use MLB with HTTP/2?

Yes, but it will break certain features due to how the current implementations work. Here is a demo of using MLB with nginx and HTTP/2.