docker - 将 Ubuntu Docker 容器作为 Marathon 应用程序运行不断重启

标签 docker ubuntu containers mesos marathon

嗨,我正在尝试在马拉松应用程序中运行 ubuntu docker,这是我的服务配置:

{
"id": "/h",
"backoffFactor": 1.15,
"backoffSeconds": 1,
"container": {
    "type": "DOCKER",
    "volumes": [],
    "docker": {
        "image": "ubuntu",
        "forcePullImage": false,
        "privileged": true,
        "parameters": [{
                "key": "detach",
                "value": "true"
            },
            {
                "key": "tty",
                "value": "true"
            },
            {
                "key": "interactive",
                "value": "true"
            }
        ]
    }
},
"cpus": 1,
"disk": 10000,
"instances": 0,
"maxLaunchDelaySeconds": 3600,
"mem": 1028,
"gpus": 0,
"networks": [{
    "mode": "host"
}],
"portDefinitions": [],
"requirePorts": false,
"upgradeStrategy": {
    "maximumOverCapacity": 1,
    "minimumHealthCapacity": 1
},
"killSelection": "YOUNGEST_FIRST",
"unreachableStrategy": {
    "inactiveAfterSeconds": 0,
    "expungeAfterSeconds": 0
},
"healthChecks": [],
"fetch": [],
"constraints": []

}

我尝试设置 --detach 和 --tty在后台运行 ubuntu 容器并使其保持事件状态的选项,我尝试的另一件事是 "cmd": "-sleep 1000000000"但是刚开始,任务会在不到一秒的时间内完成并开始另一个任务!
如何启动 docker 容器并使其在后台运行?

最佳答案

试试下面的马拉松配置:

{
  "id": "/test-ubuntu",
  "backoffFactor": 1.15,
  "backoffSeconds": 1,
  "cmd": "tail -f /dev/null",
  "container": {
    "type": "DOCKER",
    "volumes": [],
    "docker": {
      "image": "ubuntu",
      "forcePullImage": false,
      "privileged": true,
      "parameters": []
    }
  },
  "cpus": 1,
  "disk": 10000,
  "instances": 1,
  "maxLaunchDelaySeconds": 3600,
  "mem": 1028,
  "gpus": 0,
  "networks": [
    {
      "mode": "host"
    }
  ],
  "portDefinitions": [],
  "requirePorts": false,
  "upgradeStrategy": {
    "maximumOverCapacity": 1,
    "minimumHealthCapacity": 1
  },
  "killSelection": "YOUNGEST_FIRST",
  "unreachableStrategy": {
    "inactiveAfterSeconds": 0,
    "expungeAfterSeconds": 0
  },
  "healthChecks": [],
  "fetch": [],
  "constraints": []
}

Docker 容器需要在前台运行的入口点。
试试下面的 cmd :
    "cmd": "tail -f /dev/null"

关于docker - 将 Ubuntu Docker 容器作为 Marathon 应用程序运行不断重启,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53447718/

相关文章:

docker - Docker 中的小写图像名称

linux - 通过 CLI 修改目录中的所有文件名 - Ubuntu

azure - 如何从 Azure blob 容器获取所有/部分文件 (CloudBlockBlob)?

C#,容器的火灾事件

netbeans - 恢复 netbeans 本地历史

templates - 使用 boost::graph 实现异构节点类型和边类型

reactjs - Docker 找不到语义-ui-react

php - Docker:Nginx + PHP-FPM和多个站点

docker - Docker日志填充正在运行的容器

bash - 如何定义一个 shell 脚本变量以在脚本之外具有作用域