用jenkins在kubernetes实例上使用docker-compose - 安装空卷 [英] using docker-compose on a kubernetes instance with jenkins - mounting empty volumes

查看:235
本文介绍了用jenkins在kubernetes实例上使用docker-compose - 安装空卷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Google的Jenkins实例设置 Jenkins on Kubernetes

一个解决方案。我没有改变Kubernetes Pod的任何设置。



当我触发一项新工作时,我能够成功地启动和运行一切,直到我的测试点。



我的测试使用docker-compose。首先我确保在实例上安装docker(1.5-1 + b1)和docker-compose(1.8.0-2)(我知道我可以通过使用已经包含这些图片的图片来优化这个,但我仍然只是在验证的概念)。

当我运行 docker-compose up 命令时,一切正常,服务启动它们的初始化脚本。但是,坐骑是空的。我已经验证了Jenkins从服务器上存在的文件,并且在运行docker-compose时,在docker服务中创建了挂载,但是它们是空的



一些信息:

为了避开文件权限,我使用 / tmp 作为Jenkins工作区。我使用SCM来拉取我的文件(成功),并在docker-compose文件中指定 version:'2'和绝对路径的装载路径。失败服务的体积部分如下所示:

 卷:
- / tmp / automation:/ opt / automation

我将服务中运行的命令更改为 ls / opt / automation ,结果是一个空目录。



我缺少什么? 我只想将一个目录加载到我的docker-compose服务中。这完美地从Windows,Ubuntu和Centos设备运作。为什么它不能使用Kubernetes实例?

解决方案

我找到了失败的原因在这里
$ b


Docker容器中的Docker容器使用父HOST的Docker守护进程,因此挂载的所有卷在docker-in-docker情况下仍然是从HOST引用的,而不是从Container引用的。

因此,从Jenkins容器安装的实际路径不存在在HOST中。由于这个原因,在空的docker-in-docker容器中创建了一个新的目录。当一个目录被挂载到Container中的新Docker容器时,同样的情况也适用。


所以看起来好像不可能挂载从外部码头到内部码头的东西。另一个解决方案必须找到。


I have a Jenkins instance setup using Googles Jenkins on Kubernetes solution. I have not changed any of the settings of the Kubernetes Pod.

When I trigger a new job I am successfully able to get everything up and running until the point of my tests.

My tests use docker-compose. First I make sure to install docker (1.5-1+b1) and docker-compose (1.8.0-2) on the instance (I know I can optimize this by using an image that already includes these, but I am still just in proof-of-concept).

When I run the docker-compose up command everything works and the services start their initialization scripts. However, the mounts are empty. I have verified that the files exist on the Jenkins slave, and the mount is created inside the docker service when I run docker-compose, however they are empty.

Some information:

In order to get around file permissions I am using /tmp as the Jenkins Workspace. I am using SCM to pull my files (successfully) and in the docker-compose file I specify version: '2' and the mount paths with absolute paths. The volume section of the service that fails looks like this:

volumes:
 - /tmp/automation:/opt/automation

I changed the command that is run in the service to ls /opt/automation and the result is an empty directory.

What am I missing? I just want to mount a directory into my docker-compose service. This works perfectly from Windows, Ubuntu, and Centos devices. Why won't it work using the Kubernetes instance?

解决方案

I found the reason it fails here:

A Docker container in a Docker container uses the parent HOST's Docker daemon and hence, any volumes that are mounted in the "docker-in-docker" case is still referenced from the HOST, and not from the Container.

Therefore, the actual path mounted from the Jenkins container "does not exist" in the HOST. Due to this, a new directory is created in the "docker-in-docker" container that is empty. Same thing applies when a directory is mounted to a new Docker container inside a Container.

So it seems like it will be impossible to mount something from the outer docker into the inner docker. And another solution must be found.

这篇关于用jenkins在kubernetes实例上使用docker-compose - 安装空卷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆