Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
  }
]
like image 603
Kuldeep Dangi Avatar asked Jan 09 '18 07:01

Kuldeep Dangi


People also ask

What is the difference between container port and host port?

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.

What is host port and container port in Docker?

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.

Can host port and container port be same?

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.

What is container port in AWS?

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 .


1 Answers

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

like image 54
Mateusz Moneta Avatar answered Sep 23 '22 23:09

Mateusz Moneta