代码之家  ›  专栏  ›  技术社区  ›  Patrick

Jenkins&Gitlab&Docker集成失败

  •  2
  • Patrick  · 技术社区  · 6 年前

    詹金斯

    在詹金斯,我决定使用远程Docker功能。 所以我安装了 docker.io 在Linux服务器上,并使用此管道。

    node {
        stage('Example') {
            docker.withServer('tcp://docker.example.org:2375') {
                docker.image('stefanscherer/node-windows:10').inside {
                    sh 'node --version'
                }
            }
        }
    }
    

    但这失败了,并显示有关卷配置的错误消息。

    java.io.IOException: Failed to run image 'stefanscherer/node-windows:10'. Error: docker: Error response from daemon: invalid volume specification: '/var/lib/jenkins/workspace/Docker Test:/var/lib/jenkins/workspace/Docker Test:rw,z'.
    See 'docker run --help'.
        at org.jenkinsci.plugins.docker.workflow.client.DockerClient.run(DockerClient.java:133)
    

    可能问题是我试图将Linux Jenkins与Docker Windows结合在一起? 但我读到的是 experimental 允许使用Linux容器的选项。

    吉特实验室

    通过本指南安装的Gitlab Runner。 https://docs.gitlab.com/runner/install/windows.html 然后我连接它并选择 docker 作为执行人。

    当我移除 hosts daemon.json 我收到这个错误消息。

    ERROR: Preparation failed: Error response from daemon: client version 1.18 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version (executor_docker.go:1161:0s)
    

    如何获得支持较新API的版本? 我读到一篇文章说Gitlab正在等待LTS EOL(生命的终结)。我想是为了百分之一或别的什么。

    当我有 宿主 设置在 杰森 我收到这个错误消息。

    ERROR: Preparation failed: error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.18/info: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running. (executor_docker.go:1161:0s)
    

    这是因为运行程序找不到Docker,因为Docker只在监听TCP端口。 我试着加 //./pipe/docker_engine 宿主 属于 杰森 但它不起作用。码头服务立即崩溃。

    码头工人

    Windows服务器2016

    杰森

    {
        "hosts": ["tcp://0.0.0.0:2375"],
        "experimental": true
    }
    

    目标

    我的目标是在(Windows)Docker上使用(Linux)Jenkins和(Linux)Gitlab构建我的工作。

    问题

    詹金斯 由于某些设置,或者因为它试图挂载Windows路径,所以通常不工作吗?

    吉特实验室 期待一个老的API,码头工人不提供。

    1 回复  |  直到 6 年前
        1
  •  1
  •   Carlos Cavero ABU    6 年前

    目标

    您所处的位置是正确的,分发您的CI管道可以方便地进行烫伤,容器是实现这一点的理想解决方案。

    詹金斯

    Docker Pipeline Jenkins documentation 解释如下:

    要使inside()工作,Docker服务器和Jenkins代理必须使用 相同的文件系统,以便可以装载工作区。

    所以,使用其他命令(例如withrun)进行一次尝试,看看在任何情况下,我都会错过一些凭据。您还可以为Docker配置一个新的Jenkins节点,在那里您可以指定执行作业的路径。

    吉特实验室

    如前所述,Windows上的Gitlab Runner问题计划包含在11.8版本(2019年2月)中。 here .

    结论

    如果您不能等到新的Gitlab版本,我将进行Linux安装,并按照描述为Docker配置添加一个新的Jenkins节点。 here .