Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker + Marathon : how to do a port mapping ?

I am trying to launch rstudio on my infrastructure.

If I do :

sudo docker run -d -p 8787:8787 192.168.0.38:5000/rocker/rstudio

Then I have rstudio running fine on my server. But I have mesos and marathon, and would like to make a Marathon's app out of this docker command.

I can't find the way to map correctly the port.

I tried :

{
  "type": "DOCKER",
  "volumes": [],
  "docker": {
    "image": "192.168.0.38:5000/rocker/rstudio",
    "network": "HOST",
    "privileged": true,
    "parameters": [
      {
        "key": "p",
        "value": "8787:8787"
      }
    ],
    "forcePullImage": true
  }
}

Hopping that I would work, but it never starts.

And I tried :

{
  "type": "DOCKER",
  "volumes": [],
  "docker": {
    "image": "192.168.0.38:5000/rocker/rstudio",
    "network": "HOST",
    "portMappings": [
      {
        "containerPort": 8787,
        "hostPort": 8787,
        "servicePort": 10003,
        "protocol": "tcp"
      }
    ],
    "privileged": true,
    "parameters": [],
    "forcePullImage": true
  }
}

Which is not better.

Which json would you suggest me to convert this working docker command :

sudo docker run -d -p 8787:8787 192.168.0.38:5000/rocker/rstudio

??

like image 614
Romain Jouin Avatar asked Feb 08 '23 02:02

Romain Jouin


1 Answers

The port mapping is (as with Docker) only relevant for BRIDGE networking mode, see also the Marathon doc. In your case the following should work:

...
"container": {
  "type": "DOCKER",
  "docker": {
    "network": "BRIDGE",
    "portMappings": [
      {
        "protocol": "tcp",
        "containerPort": 8787,
        "hostPort": 8787
      }
    ]
  }
},
...

Mesosphere doc

like image 118
Michael Hausenblas Avatar answered Feb 13 '23 02:02

Michael Hausenblas