在马拉松中将docker容器作为任务运行

时间:2016-09-26 06:09:37

标签: docker mesos mesosphere marathon

我在本地系统上设置了mesos和marathon。另外,我在我的系统上运行了docker引擎,当我这样做时sudo docker images,我得到以下内容,

REPOSITORY                                                 TAG                 IMAGE ID            CREATED             SIZE
myrepo/hello                                               latest              b7ce0084dbaf        4 weeks ago         330.3 MB
fluent/new                                                 latest              adc4b7b4b0eb        4 weeks ago         1.589 GB
<none>                                                     <none>              3a87799875ed        4 weeks ago         1.589 GB
<none>                                                     <none>              16a573cd3b85        4 weeks ago         330.3 MB
769348183957.dkr.ecr.us-east-1.amazonaws.com/ruby          2.1.10              77bf121d484e        8 weeks ago         1.535 GB
769348183957.dkr.ecr.us-east-1.amazonaws.com/centos-base   7                   9ab68a0dd16a        10 weeks ago        330.3 MB
hello-world                                                latest              c54a2cc56cbb        12 weeks ago        1.848 kB
docker/whalesay                                            latest              6b362a9f73eb        16 months ago       247 MB

现在,通过Marathon UI,我正在尝试创建一个应用程序,在完成https://mesosphere.github.io/marathon/docs/native-docker-private-registry.html文档中的所有步骤后,当我最终创建应用程序时,它的状态在间歇性地部署和等待之间变化最后显示延迟。我从来没有在跑步阶段得到它。我试图弄清楚我的机器上的日志,但我无法理解它们的音量。

我的应用程序的JSON配置如下:

{
  "id": "/123",
  "cmd": "sudo docker run -itd 9ab68a0dd16a /bin/bash",
  "cpus": 1,
  "mem": 128,
  "disk": 200,
  "instances": 1,
  "container": {
    "docker": {
      "image": "769348183957.dkr.ecr.us-east-1.amazonaws.com/centos-base",
      "network": "HOST",
      "forcePullImage": true
    },
    "type": "DOCKER"
  }
}

我错过了什么吗? AFAIK,应该发生的是应用程序应该自动从我的本地仓库中提取这个图像,最后部署在机器上。我是否还应该为我的应用程序创建任务,因为我没有专门做任何任务?如果是,我不是必须首先创建一个应用程序,然后向其添加任务吗?

另外,我重新启动了mesos slave,如下所示:sudo ./bin/mesos-slave.sh --master=127.0.0.1:5050 --work_dir=/var/lib/mesos --containerizers=docker,mesos --executor_registration_timeout=5mins

另外,我尝试在我的localhost上创建docker repo的tar.gz文件并将其复制到/ etc并传递URI: file///etc/docker.repo.tar.gz

我哪里错了?在马拉松日志中,我能够看到None of the enabled containerizers (mesos) could create a container for the provided TaskInfo/ExecutorInfo message。因此,我认为这是我出错的地方。

编辑:建议的应用程序的Marathon日志:

[2016-09-26 12:29:30,418] INFO Task launch for 'task [nginx.c59c7403-83b6-11e6-a834-0a0027000000]' was accepted. 0 tasksToLaunch, 0 in flight, 1 confirmed.  not backing off (mesosphere.marathon.core.launchqueue.impl.AppTaskLauncherActor:marathon-akka.actor.default-dispatcher-8)
I0926 12:29:30.418325 90841088 master.cpp:3104] Processing ACCEPT call for offers: [ d165ac5e-93dc-4b7b-bf36-071ce75aa44d-O17 ] on slave d165ac5e-93dc-4b7b-bf36-071ce75aa44d-S0 at slave(1)@172.26.35.124:63837 (172.26.35.124) for framework fa8c0ef7-651b-41c2-8f1c-c24057bcfb58-0000 (marathon) at scheduler-c27b723e-e9d3-428a-b7d3-c8c184b1ed7c@172.26.35.124:63837
I0926 12:29:30.419334 90841088 master.hpp:177] Adding task nginx.c59c7403-83b6-11e6-a834-0a0027000000 with resources cpus(*):0.1; mem(*):256; ports(*):[31835-31835] on slave d165ac5e-93dc-4b7b-bf36-071ce75aa44d-S0 (172.26.35.124)
I0926 12:29:30.419400 90841088 master.cpp:3589] Launching task nginx.c59c7403-83b6-11e6-a834-0a0027000000 of framework fa8c0ef7-651b-41c2-8f1c-c24057bcfb58-0000 (marathon) at scheduler-c27b723e-e9d3-428a-b7d3-c8c184b1ed7c@172.26.35.124:63837 with resources cpus(*):0.1; mem(*):256; ports(*):[31835-31835] on slave d165ac5e-93dc-4b7b-bf36-071ce75aa44d-S0 at slave(1)@172.26.35.124:63837 (172.26.35.124)
I0926 12:29:30.419661 89767936 slave.cpp:1361] Got assigned task nginx.c59c7403-83b6-11e6-a834-0a0027000000 for framework fa8c0ef7-651b-41c2-8f1c-c24057bcfb58-0000
I0926 12:29:30.421689 90304512 gc.cpp:83] Unscheduling '/tmp/mesos/0/slaves/d165ac5e-93dc-4b7b-bf36-071ce75aa44d-S0/frameworks/fa8c0ef7-651b-41c2-8f1c-c24057bcfb58-0000' from gc
I0926 12:29:30.422006 89767936 gc.cpp:83] Unscheduling '/tmp/mesos/0/meta/slaves/d165ac5e-93dc-4b7b-bf36-071ce75aa44d-S0/frameworks/fa8c0ef7-651b-41c2-8f1c-c24057bcfb58-0000' from gc
I0926 12:29:30.422173 88158208 slave.cpp:1480] Launching task nginx.c59c7403-83b6-11e6-a834-0a0027000000 for framework fa8c0ef7-651b-41c2-8f1c-c24057bcfb58-0000
I0926 12:29:30.422904 88158208 paths.cpp:528] Trying to chown '/tmp/mesos/0/slaves/d165ac5e-93dc-4b7b-bf36-071ce75aa44d-S0/frameworks/fa8c0ef7-651b-41c2-8f1c-c24057bcfb58-0000/executors/nginx.c59c7403-83b6-11e6-a834-0a0027000000/runs/0548c84c-40ad-40cd-bbd8-b1330e66f348' to user 'bhjain'
I0926 12:29:30.445124 88158208 slave.cpp:5352] Launching executor nginx.c59c7403-83b6-11e6-a834-0a0027000000 of framework fa8c0ef7-651b-41c2-8f1c-c24057bcfb58-0000 with resources cpus(*):0.1; mem(*):32 in work directory '/tmp/mesos/0/slaves/d165ac5e-93dc-4b7b-bf36-071ce75aa44d-S0/frameworks/fa8c0ef7-651b-41c2-8f1c-c24057bcfb58-0000/executors/nginx.c59c7403-83b6-11e6-a834-0a0027000000/runs/0548c84c-40ad-40cd-bbd8-b1330e66f348'
I0926 12:29:30.446513 88158208 slave.cpp:1698] Queuing task 'nginx.c59c7403-83b6-11e6-a834-0a0027000000' for executor 'nginx.c59c7403-83b6-11e6-a834-0a0027000000' of framework fa8c0ef7-651b-41c2-8f1c-c24057bcfb58-0000
E0926 12:29:30.446702 88158208 slave.cpp:3784] Container '0548c84c-40ad-40cd-bbd8-b1330e66f348' for executor 'nginx.c59c7403-83b6-11e6-a834-0a0027000000' of framework fa8c0ef7-651b-41c2-8f1c-c24057bcfb58-0000 failed to start: **None of the enabled containerizers (mesos) could create a container for the provided TaskInfo/ExecutorInfo message**
E0926 12:29:30.446846 90841088 slave.cpp:3855] Termination of executor 'nginx.c59c7403-83b6-11e6-a834-0a0027000000' of framework fa8c0ef7-651b-41c2-8f1c-c24057bcfb58-0000 failed: Unknown container: 0548c84c-40ad-40cd-bbd8-b1330e66f348
I0926 12:29:30.453965 90841088 slave.cpp:3012] Handling status update TASK_FAILED (UUID: 90717092-98c0-4eab-9967-f43e005159b5) for task nginx.c59c7403-83b6-11e6-a834-0a0027000000 of framework fa8c0ef7-651b-41c2-8f1c-c24057bcfb58-0000 from @0.0.0.0:0
W0926 12:29:30.454391 91914240 containerizer.cpp:1295] Ignoring update for unknown container: 0548c84c-40ad-40cd-bbd8-b1330e66f348
I0926 12:29:30.454927 91377664 status_update_manager.cpp:320] Received status update TASK_FAILED (UUID: 90717092-98c0-4eab-9967-f43e005159b5) for task nginx.c59c7403-83b6-11e6-a834-0a0027000000 of framework fa8c0ef7-651b-41c2-8f1c-c24057bcfb58-0000
I0926 12:29:30.455751 91377664 status_update_manager.cpp:824] Checkpointing UPDATE for status update TASK_FAILED (UUID: 90717092-98c0-4eab-9967-f43e005159b5) for task nginx.c59c7403-83b6-11e6-a834-0a0027000000 of framework fa8c0ef7-651b-41c2-8f1c-c24057bcfb58-0000
I0926 12:29:30.456254 90304512 slave.cpp:3410] Forwarding the update TASK_FAILED (UUID: 90717092-98c0-4eab-9967-f43e005159b5) for task nginx.c59c7403-83b6-11e6-a834-0a0027000000 of framework fa8c0ef7-651b-41c2-8f1c-c24057bcfb58-0000 to master@172.26.35.124:63837
I0926 12:29:30.456456 91377664 master.cpp:4763] Status update TASK_FAILED (UUID: 90717092-98c0-4eab-9967-f43e005159b5) for task nginx.c59c7403-83b6-11e6-a834-0a0027000000 of framework fa8c0ef7-651b-41c2

1 个答案:

答案 0 :(得分:0)

从JSON架构的角度来看,JSON似乎很好。 TBH,如果你想在Mesos上测试运行容器,cmd属性内容真的没有用。

我甚至认为你正在使用的命令无法工作,在应用程序上下文中执行Docker ......

请使用像nginx这样的标准图片:

{
  "id": "nginx",
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "nginx",
      "network": "BRIDGE",
      "portMappings": [
        { "hostPort": 0, "containerPort": 80 }
      ],
      "forcePullImage":true
    }
  },
  "instances": 1,
  "cpus": 0.1,
  "mem": 256,
  "healthChecks": [{
      "protocol": "HTTP",
      "path": "/",
      "portIndex": 0,
      "timeoutSeconds": 10,
      "gracePeriodSeconds": 10,
      "intervalSeconds": 2,
      "maxConsecutiveFailures": 10
  }]
}

检查整体功能。如果此方法有效,请将nginx图像标记并推送到本地注册表,然后尝试通过uris凭据传递方法和本地图像名称使用它。