Marathon endpoint link and host networking

81 views
Skip to first unread message

matteo.p...@brightcomputing.com

unread,
Jul 19, 2016, 5:32:52 AM7/19/16
to marathon-framework
Hello everyone,

I'm study mesos and marathon to schedule docker container.
I have an issue when creating a container with host networking, the endpoint link in marathon doesn't reflect the actual port exposed by the container.

For example I have a container running a simple python http server on port 9090, If I open the browser pointing to node002:9090 I can reach the webserver:

[root@node002 ~]# docker inspect --format='{{ .Args }}' mesos-3d93450b-d3b0-4665-b2bf-caf7c825cc8c-S0.6100a615-930d-4f75-8689-dd23955bf3a9
[-c python3 -m http.server 9090]

[root@node002 ~]# lsof -i :9090
COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
python3 3221 root    4u  IPv4  29629      0t0  TCP *:websm (LISTEN)

But the endpoint link on marathon point to another port "node002:4681" instead of 9090.

What I'm doing wrong?

Is anyone else experiencing the same issue?

I'm running the following mesos/marathon version on centos 7u2:

[root@cluster1-headnode1 ~]# rpm -qa |grep -Ew 'mesos|marathon'
marathon-1.1.1-1.0.472.el7.x86_64
mesos-0.28.1-2.0.20.centos701406.x86_64

Thanks in advance.

Cheers,
Matteo

Tomek Janiszewski

unread,
Jul 19, 2016, 6:54:52 AM7/19/16
to matteo.p...@brightcomputing.com, marathon-framework
Hi

Could you show how your application JSON looks like? I suspect you didn't specify ports, so marathon took random port which docker ignore and bind on 9090. I think #1618 is related to your question.

Best
Tomek

--
You received this message because you are subscribed to the Google Groups "marathon-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to marathon-framew...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

matteo.p...@brightcomputing.com

unread,
Jul 20, 2016, 6:21:52 AM7/20/16
to marathon-framework, matteo.p...@brightcomputing.com
Hi Tomek,

Thanks for your reply.

> Could you show how your application JSON looks like? I suspect you didn't specify ports

This is the JSON I'm submitting:

### START ###

{
 "id": "test-host-port-9090",
 "cmd": "python3 -m http.server 9090",
 "cpus": 1,
 "mem": 128,
 "disk": 0,
 "instances": 1,
 "container”: {
   "docker": {
     "image": "python:3",
     "network": "HOST"
   },
   "type": "DOCKER",
   "volumes": []
 },
 "portDefinitions": [
   {   
     "port": 0,
     "protocol": "tcp",
     "name": null,
     "labels": null
   } 
 ],
 "env": {},
 "labels": {},
 "healthChecks": []
}
 
### END ###
           
I just tried the following JSON but I have the same result, a random port is used for the endpoint link and the container bind to 9090.
             
### START ###
 
{
 "id": "test-host-port-9090",
 "cmd": "python3 -m http.server 9090",
 "cpus": 0.1,
 "mem": 128,
 "disk": 0,
 "instances": 1,
 "ports": [9090],
 "container": {
   "docker": {
     "image": "python:3",
     "network": "HOST"
   },
   "type": "DOCKER"
 }
}

### END ###

Do you have any other suggestion?

Thanks.

Best,
Matteo

Tomek Janiszewski

unread,
Jul 20, 2016, 7:51:46 AM7/20/16
to matteo.p...@brightcomputing.com, marathon-framework
You need to specify requirePorts see https://mesosphere.github.io/marathon/docs/ports.html

matteo.p...@brightcomputing.com

unread,
Jul 20, 2016, 8:52:20 AM7/20/16
to marathon-framework, matteo.p...@brightcomputing.com
Hello Tomek,

Thanks very much for your help, issue (Mistake) solved.
With the following JSON using ports and requirePorts the endpoint link in marathon point to the port 9090 instead of a random one.
Fortunately it wasn't a bug :-)

### START ###

{
 "id": "test-host-port-9090",
 "cmd": "python3 -m http.server 9090",
 "cpus": 0.1,
 "mem": 128,
 "disk": 0, 
 "instances": 1, 
 "ports": [9090],
 "requirePorts" : true,
 "container": {
   "docker": {
     "image": "python:3",
     "network": "HOST"
   }, 
   "type": "DOCKER",
   "volumes": [] 
 }
}

### END ###

Best,
Matteo

Reply all
Reply to author
Forward
0 new messages