嗨,我正在尝试在马拉松应用中运行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容器并使它在后台运行?
答案 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"