Deploying an Externally Load Balanced App with Marathon-LB

This tutorial shows you how to use Marathon-LB to run a containerized DC/OS service that serves a website. Specifically, you will use Docker image that contains NGINX, which serves the site.

In this tutorial, Marathon-LB is used as the edge load balancer and service discovery mechanism. Marathon-LB is run on a public-facing node to route ingress traffic.


Configure and Run a Containerized Service on a Public Node

  1. Copy dcos-website/dcos-website.json from the dcos-website GitHub repository.

    1. Go to the mesosphere/dcos-website Docker Hub repository and copy the latest image tag.

      Mesosphere Docker Hub

    2. Replace <image-tag> in the docker:image field with the tag.

    3. Locate and take note of your public agent node IP address.

    4. In the labels field, add an entry for HAPROXY_0_VHOST and assign it the value of your public agent IP. Remove the leading http:// and the trailing / from the IP. Remember to add a comma after the preceding field.

      The complete JSON service definition file should resemble:

        "id": "dcos-website",
        "container": {
          "type": "DOCKER",
          "portMappings": [
            { "hostPort": 0, "containerPort": 80, "servicePort": 10004 }
          "docker": {
            "image": "mesosphere/dcos-website:<image-tag>"
        "instances": 3,
        "cpus": 0.25,
        "mem": 100,
        "networks": [ { "mode": "container/bridge" } ],
        "healthChecks": [{
            "protocol": "HTTP",
            "path": "/",
            "portIndex": 0,
            "timeoutSeconds": 2,
            "gracePeriodSeconds": 15,
            "intervalSeconds": 3,
            "maxConsecutiveFailures": 2
          "HAPROXY_0_VHOST": "<public-agent-ip>"
  2. Run the service from the DC/OS CLI using the following command:

    dcos marathon app add dcos-website.json
  3. Go to the Services tab of the DC/OS web interface to verify that your application is healthy.

    Healthy Service

  4. Go to your public agent to see the site running. For information about how to find your public agent IP, see the documentation.