如何在DC操作系统中强制执行docker镜像?

对于docker编排,我们正在使用mesos和chronos来安排作业运行。

现在,我们放弃了计时器,并试图通过DCO设置,使用mesos和节拍器。

在chronos中,我可以通过它的ymlconfiguration激活强制拖动docker镜像:

container: type: docker image: registry.example.com:5001/the-app:production forcePullImage: true 

现在,在使用节拍器和介面的DC / OS中,我也希望它强制它总是从registry中取出最新的图像,而不是依赖于它的caching版本。

然而,docker的JSONconfiguration似乎有限:

 "docker": { "image": "registry.example.com:5001/the-app:production" }, 

如果我将新图像推送到production标签,旧图像将用于mesos上的作业。

为了这个原因,我尝试join这个标志:

 "docker": { "image": "registry.example.com:5001/my-app:staging", "forcePullImage": true }, 

但在请求中,我得到一个错误:

 http PUT example.com/service/metronome/v1/jobs/the-app < app-config.json HTTP/1.1 422 Unprocessable Entity Connection: keep-alive Content-Length: 147 Content-Type: application/json Date: Fri, 12 May 2017 09:57:55 GMT Server: openresty/1.9.15.1 { "details": [ { "errors": [ "Additional properties are not allowed but found 'forcePullImage'." ], "path": "/run/docker" } ], "message": "Object is not valid" } 

我怎样才能达到直stream操作系统总是拉最新的形象? 还是必须始终通过独特的图像标签更新作业定义?

由于这是目前不可能,我创build了一个function请求要求这个function。


与此同时,我创build了解决方法,能够使用打字稿和请求承诺库更新所有已注册作业的图像标签。

基本上我从节拍器api中获取所有的工作,通过id从我的应用名称开始过滤,然后更改docker镜像,然后为每个更改的工作发出一个PUT请求到节拍器api来更新configuration。

这是我的解决scheme:

 const targetTag = 'stage-build-1501'; // currently hardcoded, should be set via jenkins run const app = 'my-app'; const dockerImage = `registry.example.com:5001/${app}:${targetTag}`; interface JobConfig { id: string; description: string; labels: object; run: { cpus: number, mem: number, disk: number, cmd: string, env: any, placement: any, artifacts: any[]; maxLaunchDelay: 3600; docker: { image: string }; volumes: any[]; restart: any; }; } const rp = require('request-promise'); const BASE_URL = 'http://example.com'; const METRONOME_URL = '/service/metronome/v1/jobs'; const JOBS_URL = BASE_URL + METRONOME_URL; const jobsOptions = { uri: JOBS_URL, headers: { 'User-Agent': 'Request-Promise', }, json: true, }; const createJobUpdateOptions = (jobConfig: JobConfig) => { return { method: 'PUT', body: jobConfig, uri: `${JOBS_URL}/${jobConfig.id}`, headers: { 'User-Agent': 'Request-Promise', }, json: true, }; }; rp(jobsOptions).then((jobs: JobConfig[]) => { const filteredJobs = jobs.filter((job: any) => { return job.id.includes('job-prefix.'); // I don't want to change the image of all jobs, only for the same application }); filteredJobs.map((job: JobConfig) => { job.run.docker.image = dockerImage; }); filteredJobs.map((updateJob: JobConfig) => { console.log(`${updateJob.id} to be updated!`); const requestOption = createJobUpdateOptions(updateJob); rp(requestOption).then((response: any) => { console.log(`Updated schedule for ${updateJob.id}`); }); }); }); 

我有一个类似的问题,我的图像回购已validation,我不能提供使用节拍器语法必要的身份validation信息。 我通过指定2个命令而不是直接引用图像来解决这个问题。

 docker --config /etc/.docker pull docker --config /etc/.docker run 

我认为"forcePullImage": true应该与docker字典一起工作。

检查: https : //mesosphere.github.io/marathon/docs/native-docker.html

看看“强制拉动选项”。

Interesting Posts