0

I have marathon/mesos successfully deploying app, but if I add a port mapping, it doesn't work anymore.

My slave container is runned as :

docker run --privileged -v /data/docker/notebook:/notebook:rw -v /etc/localtime:/etc/localtime:ro --net=host -e NFS_PATH=$NFS_PATH -e IP=$IP -e RESOURCES=$RESOURCES -e ATTRIBUTES=$ATTRIBUTES -e HOSTNAME=$HOSTNAME  -e MASTER=$MASTER -e SLAVE_PORT=$SLAVE_PORT  -d -p 5151:5151 --name $CONTAINER_NAME $IMAGE_NAME

Then in the slave container I have to start by hand the daemon because of a strange [time="2015-10-17T12:27:40.963674511Z" level=fatal msg="Error starting daemon: error initializing graphdriver: operation not permitted"] error, so I do :

docker -d -D --insecure-registry=localhost:5000  -g /var/test

Then I see my slave on Mesos as a working ressource, and I can post some app to marathon :

    {
  "id": "rstudiorocker2",
  "container": {
    "type"      : "DOCKER",
    "volumes"   : [],
    "docker"    : {
                "image"             : "localhost:5000/rocker/rstudio",
                "privileged"        : true,
                "parameters"        : [],
                "forcePullImage"        : true
                }
    }
}

Here the app is instantaenously deployed on the slave. The issue is that rocker is listening on port 8787, and I want to access on it on another port, so I try to make a port mapping :

{
  "id": "rstudiorocker",
  "container": {
    "type"      : "DOCKER",
    "volumes"   : [],
    "docker"    : {
                "image"             : "192.168.0.38:5000/rocker/rstudio",
                "privileged"        : true,
                "parameters"        : [],
                "forcePullImage"        : true,
"network":"BRIDGE", 
"portMappings": [
                    { "containerPort": 8787, 
                    "hostPort": 2036, 
                    "protocol": "tcp" }
                , { "containerPort": 8787,
                    "hostPort": 2036,
                    "protocol": "udp" }
                ]}

    }

}

and here the problem appear : the app stay on "stagging" stage, without never being deployed (even if I delete all other app first) :( What could go wrong ?

Romain Jouin
  • 4,448
  • 3
  • 49
  • 79

1 Answers1

0

You've tried to map the same container port twice, which is not allowed by Marathon:

"portMappings": [
  { "containerPort": 8787, 
    "hostPort": 2036, 
    "protocol": "tcp" },
  { "containerPort": 8787,
    "hostPort": 2036,
    "protocol": "udp" }
]}

Marathon will reject this configuration with a message like

{"message":"Bean is not valid","errors":[{"attribute":"ports","error":"Elements must be unique"}]}

Try changing one of the containerPort values, eg:

"portMappings": [
  { "containerPort": 8787, 
    "hostPort": 0, 
    "protocol": "tcp" },
  { "containerPort": 8789,
    "hostPort": 0,
    "protocol": "udp" }
]}