gpt4 book ai didi

docker - 在 Jenkins 声明式管道中使用适用于 Windows 的 Docker

转载 作者:行者123 更新时间:2023-12-01 12:11:24 25 4
gpt4 key购买 nike

我正在通过 Dockerfile 使用 Jenkins 声明性管道和 Docker-for-Windows 代理设置 CI 工作流。

注意:不幸的是,目前这不是使用基于 Linux 的 docker 守护进程的解决方案,因为我需要运行 Windows 二进制文件。

设置:Jenkins master 通过 Docker 在 Linux 16.04 上运行。 Jenkins 构建代理是

  • Windows 10 企业版 1709 (16299.551)
  • Docker-for-Windows 17.12.0-ce

Docker 18.x 在尝试使用 Windows 容器时让我头疼,所以我回滚到 17.x。在尝试与 Jenkins 一起运行并且 nohup 不在路径上时,我仍然遇到一些问题,但已通过 adding Git binaries to Windows search path 解决(another reference)。我怀疑我当前的问题可能与此有关。

代码:我正在尝试初始化一个 Jenkinsfile 并在其中运行一个简单的 hello-world-printout。

/ Jenkins 文件

pipeline {
agent none
stages {
stage('Docker Test') {
agent {
dockerfile {
filename 'Dockerfile'
label 'windocker'
}
}
steps {
println 'Hello, World!'
}
}
}
}

/docker 文件

FROM python:3.7-windowsservercore
RUN python -m pip install --upgrade pip

基本上,这应该是一个干净的图像,只打印“Hello, World!”。 但它在 Jenkins 上失败了!

日志输出:

[C:\jenkins\workspace\dockerfilecd4c215a] Running shell script
+ docker build -t cbe5e0bb1fa45f7ec37a2b15566f84aa9bd08f5d -f Dockerfile .
Sending build context to Docker daemon 337.4kB

Step 1/2 : FROM python:3.7-windowsservercore
---> 340689b75c39
Step 2/2 : RUN python -m pip install --upgrade pip
---> Using cache
---> a93f446a877f
Successfully built a93f446a877f
Successfully tagged cbe5e0bb1fa45f7ec37a2b15566f84aa9bd08f5d:latest
[C:\jenkins\workspace\dockerfilecd4c215a] Running shell script
+ docker inspect -f . cbe5e0bb1fa45f7ec37a2b15566f84aa9bd08f5d
.
Cannot run program "id": CreateProcess error=2, The system cannot find the file specified

最佳答案

问题是,目前不支持 Windows。它正在调用 linux“id”命令来获取当前用户 ID。

Jenkins 有一个开放的 Pull Request 和 JIRA Ticket 来支持 Windows docker 管道:

关于docker - 在 Jenkins 声明式管道中使用适用于 Windows 的 Docker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51537015/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com