19

I am confused with what all these port signify container port,host port and service port in portMappings, below is my json

"portMappings": [
  {
    "containerPort": 9000,
    "hostPort": 9000,
    "labels": {
      "VIP_0": "/app2n:9000"
    },
    "protocol": "tcp",
    "servicePort": 10101
  }
]
Kuldeep Dangi
  • 4,126
  • 5
  • 33
  • 56

2 Answers2

16
  • 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>

Mateusz Moneta
  • 1,500
  • 1
  • 10
  • 7
0

A targetPort This is the port on the pod that the request gets sent to. Your application needs to be listening for network requests on this port for the service to work. These ports are typically used in service yaml descriptors.