【问题标题】:Accessing containers launched in a DC/OS Marathon Pod访问在 DC/OS Marathon Pod 中启动的容器
【发布时间】:2021-01-03 22:55:53
【问题描述】:

使用 DC/OS 文档中的示例,如果我使用以下定义启动 pod,我可以看到该 pod 已成功部署。

{
   "id":"/pod-with-endpoint",
   "containers":[
      {
         "name":"simple-docker",
         "resources":{
            "cpus":1,
            "mem":128,
            "disk":0,
            "gpus":0
         },
         "image":{
            "kind":"DOCKER",
            "id":"nginx"
         },
         "endpoints":[
            {
               "name":"web",
               "containerPort":80,
               "protocol":[
                  "http"
               ]
            }
         ]
      }
   ],
   "networks":[
      {
         "mode":"container"
      }
   ]
}

运行 dcos marathon pod list 会显示以下内容:

ID+TASKS            INSTANCES  VERSION                   STATUS  STATUS SINCE             WAITING
/pod-with-endpoint      1      2018-02-17T11:10:50.047Z  STABLE  2018-02-17T11:10:51.43Z  False
 |-simple-docker

然后我怎样才能访问 nginx 容器?

例如,如果我正在运行马拉松应用程序,我可以通过 ssh 进入运行任务的代理节点,然后通过运行 docker exec -it container_id bash 访问容器。

我在运行 docker ps 时在代理节点上看不到任何容器,大概是因为 pod 使用通用容器运行时 (UCR),所以我看不到如何连接到容器在吊舱中启动。

【问题讨论】:

    标签: docker marathon dcos


    【解决方案1】:

    您可以使用 dcos task cli 来实现:

     # Get the dcos task ID 
     dcos task [task_name]
    
     # Run task exec with task id and command to run
     dcos task exec [--interactive --tty] <task_id> <cmd> [<args>...]
    
     # Example
     dcos task exec --interactive --tty hello-world.df11367a-664354-11e8-8e5a-d6f1851c7c1c bash
    

    【讨论】:

      猜你喜欢
      • 2015-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-26
      • 2019-03-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多