powershell - 尝试在 Windows 容器中使用巧克力创建 Jenkins docker 容器
问题描述
我查看了几个问题,但找不到与我的问题相匹配的任何内容。如果这是重复的,我很抱歉!
目前,我正在尝试在 dockerfile 脚本中使用巧克力创建一个 Jenkins docker 容器。我当前的脚本如下
# escape=`
# Microsoft ISO required for building Empower
FROM mcr.microsoft.com/windows/servercore:ltsc2019
SHELL ["cmd", "/S", "/C"]
# Install Chocolatey on the docker container
RUN powershell -Command `
"Set-ExecutionPolicy Bypass -Scope Process -Force; `
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; `
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"
# Install Jenkins
RUN powershell -Command `
"choco install -y jenkins"
这构建得很好,并为我生成了以下图像,我尝试将运行命令添加到
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1b18ae2b6432 724f89147e6f "-p 8080:8080" 3 minutes ago Created docker_jenkins
不幸的是,在启动容器时出现以下错误
Error response from daemon: container 1b18ae2b64329c57953b81c1fba2c3f95836f3ae0a77affe0b00bbcd18ef1125 encountered an error during hcsshim::System::CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2)
[Event Detail: Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: onecore\vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(173)\vmcomputeagent.exe!00007FF73DE39D2B: (caller: 00007FF73DDEE13A) Exception(2) tid(39c) 80070002 The system cannot find the file specified.
CallContext:[\Bridge_ProcessMessage\VmHostedContainer_ExecuteProcess]
Provider: 00000000-0000-0000-0000-000000000000] extra info: {"CommandLine":"-p 8080:8080","WorkingDirectory":"C:\\","CreateStdInPipe":true,"CreateStdOutPipe":true,"CreateStdErrPipe":true,"ConsoleSize":[0,0]}
Error: failed to start containers: docker_jenkins
我不能完全说出出了什么问题。任何有关此事的信息将不胜感激。我对码头工人和容器很陌生,所以如果这是一个愚蠢的问题,我深表歉意!
解决方案
我设法解决了这个问题。以下 dockerfile 是我最终得到的
# escape=`
# Microsoft ISO required for building Empower
FROM mcr.microsoft.com/windows/servercore:ltsc2019
# Update shell to powershell
SHELL ["powershell", "-command"]
# Install Chocolatey on the docker container
RUN Set-ExecutionPolicy Bypass -Scope Process -Force; `
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; `
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
# Install Jenkins
RUN choco install -y jenkins
推荐阅读
- python - 如何使用 SymPy 重新排列变量
- plotly-dash - 破折号数据透视表不刷新
- python - KeyError:“['1'] 在轴中找不到
- python - Python:在 DatetimeIndex 中迭代年份和月份
- http - 为什么我在逻辑应用程序中将输出视为八位字节流?
- cypress - 如何将变量从 .within() 传递给 .then()?
- c++ - 折叠表达式 () 在哪里?
- reactjs - 使用 React Table 和 Django 对大表进行分页的最佳方法是什么?(关闭)
- sql - psql:将 psql 数据库从一个帐户复制到另一个帐户
- node.js - 如何为 React Native 应用程序创建社交登录(Google、Facebook、Apple)API NodeJs Express REST?