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
}
]
Container port is available on the container IP. Hostport is available on the machine's IP. Hostport is generally a way to do things with infrastructure that you might not be able to achieve.
Port mapping is used to access the services running inside a Docker container. We open a host port to give us access to a corresponding open port inside the Docker container. Then all the requests that are made to the host port can be redirected into the Docker container.
When using BRIDGE or USER mode networking, be sure to bind your application to the containerPort s you have specified in your portMapping s. However, if you have set containerPort to 0 then this will be the same as hostPort and you can use the $PORT environment variables.
containerPort. The port number on the container that's bound to the user-specified or automatically assigned host port. If you use containers in a task with the awsvpc or host network mode, specify the exposed ports using containerPort .
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With