作为马拉松应用程序运行Ubuntu Docker容器不断重启

时间:2018-11-23 13:35:27

标签: 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容器并使它在后台运行?

1 个答案:

答案 0 :(得分:1)

尝试以下马拉松配置:

{
  "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"