Skip to content

Using your own Docker Module

Carlos Navarro edited this page Feb 13, 2017 · 3 revisions

Using your own Docker module

When using your own Docker module, it is better to deploy it using Marathon, so it can be deployed and scaled automatically.

In order to do so, it is necessary to ensure certain configurations in the Docker image and to create a Marathon configuration.

Creating a Docker image

When creating a Docker image for using with Marathon/Mesos-DNS, remember to use the EXPOSE command in the Dockerfile to expose the port of the application within the Mesos container.

Creating a Marathon configuration

When creating a Marathon configuration with Docker containers, is necessary to have a Docker Images repository. The easiest way is to have the Docker Images in Dockerhub, but any other repository can be used with the right credentials.

In the marathon configuration a "container" field, like this:

"container": {
    "type": "DOCKER",
    "docker": {
      "image": "mixedemotions/10_entity_linking_nuig",
      "network": "BRIDGE",
      "portMappings": [
        { "containerPort": 5000, "hostPort": 0, "servicePort": 0, "protocol": "tcp" }
      ]
    }
  }

The configuration "containerPort" is the exposed port, where the application is running inside the container With "hostPort": 0, we indicate marathon to map a random port to the containerPort. The "servicePort" must be unique for each module or 0 to be assigned randomly.

There are some applications that will be bind automatically to the hostPort. In those you can set containerPort to 0.

A full configuration example:

{
  "id": "entity-linking",
  "cpus": 1,
  "mem": 512.0,
  "instances": 1,
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "mixedemotions/10_entity_linking_nuig",
      "network": "BRIDGE",
      "portMappings": [
        { "containerPort": 5000, "hostPort": 0, "servicePort": 0, "protocol": "tcp" }
      ]
    }
  }

More information in Marathon documentation }

You can’t perform that action at this time.