如何使用端口Map从mesos框架启动docker容器?

7uhlpewt  于 2021-06-26  发布在  Mesos
关注(0)|答案(1)|浏览(328)

我想在自定义端口上使用mesos框架启动docker容器,但不知道如何公开端口?我无法在网桥网络中启动docker容器。我向调度程序发送接受请求,如下所示:

{
   "framework_id":{"value":"FRAMEWORK_ID"},
   "type":"ACCEPT",
   "accept":{
      "offer_ids":[{"value":"SOME ID"}],
      "operations":[
         {
            "type":"LAUNCH",
            "launch":{
               "task_infos":[
                  {
                     "name":"My Task",
                     "task_id": {"value": "12220-3440-12532-my-task"},
                     "agent_id":{"value": "AGENT_ID"},
                     "command": {"shell": false},
                     "container":{
                        "type":"DOCKER",
                        "docker":{
                           "image":"someimage/chrome",
                           "network":"BRIDGE"
                        }
                     },
                     "resources":[
                        {
                           "name":"cpus",
                           "type":"SCALAR",
                           "scalar":{"value":1.0}
                        },
                        {
                           "name":"mem",
                           "type":"SCALAR",
                           "scalar":{"value":128.0}
                        }
                     ]
                  }
               ]
            }
         }
      ],
      "filters":{"refuse_seconds":5.0}
   }
}

我不能用马拉松,所以这样不行:

"portMappings": [
      {
        "containerPort": 8080,
        "hostPort": 0,
        "servicePort": 11044,
        "protocol": "tcp",
        "labels": {}
      }
    ]

这个问题有解决办法吗?

rpppsulh

rpppsulh1#

您需要在中声明端口Map container 提出。

"container":{
                    "type":"DOCKER",
                    "docker":{
                       "image":"someimage/chrome",
                       "network":"BRIDGE"
                    }
                    "port_mappings": [
                         {
                           "host_port": <port from offer>,
                           "container_port": 8080,
                           "protocol": "tcp"
                         }
                    ]
                 },

见协议方案:https://github.com/apache/mesos/blob/1.5.0/include/mesos/mesos.proto#l3122-l3129级

相关问题