Difference between container port,host port and service port in dcos json in portMappings

  • containerPort is the port in the container, one which your containerized app should listen on,
  • hostPort is the port which will be visible on the Mesos Agent where container is running,
  • servicePort is abstract port for internal use of framework, e.g. it can be used in loadbalancer as port mapped to host on which your run your container and its hostPort. Should be unique across your cluster.

Basically flow looks like this: internet -> <loadbalancer e.g. nginx, haproxy>:<servicePort> -> <mesos agent on which container runs>:<hostPort> -> <container>:<containerPort>