Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can’;t将Choclatey安装到windows docker容器中_Windows_Docker_Dockerfile_Containers_Chocolatey - Fatal编程技术网

Can’;t将Choclatey安装到windows docker容器中

Can’;t将Choclatey安装到windows docker容器中,windows,docker,dockerfile,containers,chocolatey,Windows,Docker,Dockerfile,Containers,Chocolatey,我正在尝试将Chocolate安装到docker windows容器中,安装在使用windows容器而不是linux容器的windows 10机器上。我在PowerShell控制台中运行docker build命令,每次尝试使用以下行安装Chocolate时:Set ExecutionPolicy Bypass-Scope Process-Force;[System.Net.ServicePointManager]::SecurityProtocol=[System.Net.ServicePoi

我正在尝试将Chocolate安装到docker windows容器中,安装在使用windows容器而不是linux容器的windows 10机器上。我在PowerShell控制台中运行docker build命令,每次尝试使用以下行安装Chocolate时:
Set ExecutionPolicy Bypass-Scope Process-Force;[System.Net.ServicePointManager]::SecurityProtocol=[System.Net.ServicePointManager]::SecurityProtocol-bor 3072;iex((新对象系统.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1)

它带来了:

Exception calling "DownloadString" with "1" argument(s): "The remote name could not be resolved: 'chocolatey.org'"
 At line:1 char:166
 + ...  -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('ht ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : WebException
它似乎无法解析chocolate.org部分,我正在build命令中指定网卡:

docker build --network 21fb9a254e4b --progress=plain --tag jcontent/dockerwinbaseimage .
我还指定了守护进程文件中的DNS设置,以查看8.8.8.8。这是在测试中,在此之前它不工作

我已经附加了我的构建脚本。任何帮助都将不胜感激

# escape=`
FROM microsoft/dotnet-framework:4.7.2-sdk-windowsservercore-ltsc2016

FROM microsoft/windowsservercore:10.0.14393.1358

RUN @powershell [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12

ENV chocolateyUseWindowsCompression=false
RUN @powershell 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'))

RUN choco config set cachelocation C:\chococache

RUN choco feature enable --name allowGlobalConfirmation 

RUN choco install git; 
RUN choco install nodejs;
RUN choco install curl;
RUN choco install docker;
RUN choco install terraform;
 
# choco install visualstudio2015community --confirm --timeout 216000 \

RUN choco install dotnet4.6.1 --confirm --limit-output; 

RUN choco install visualstudio2017enterprise --package-parameters "--passive --locale en-US --includeOptional" --confirm --limit-output --timeout 216000;

RUN choco install visualstudio2017-workload-azure --confirm --limit-output --timeout 21600 --package-parameters "--includeOptional"; 
RUN choco install visualstudio2017-workload-netcoretools --confirm --limit-output --timeout 21600 --package-parameters "--includeOptional"; 
RUN choco install visualstudio2017-workload-netweb --confirm --limit-output --timeout 21600 --package-parameters "--includeOptional"; 
     

# Destroy Choclotatey cache
RUN rmdir /S /Q C:\chococache

# common node tools
RUN npm install gulp -g && npm install grunt -g && npm install -g less && npm install phantomjs-prebuilt -g;

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

# Install .NET Core
ENV DOTNET_VERSION 3.1.7
ENV DOTNET_DOWNLOAD_URL https://dotnetcli.blob.core.windows.net/dotnet/release/1.1.0/Binaries/$DOTNET_VERSION/dotnet-win-x64.$DOTNET_VERSION.zip

RUN Invoke-WebRequest $Env:DOTNET_DOWNLOAD_URL -OutFile dotnet.zip; \
RUN Expand-Archive dotnet.zip -DestinationPath $Env:ProgramFiles\dotnet -Force; \
RUN Remove-Item -Force dotnet.zip

# Install .NET Core
ENV DOTNET_VERSION 3.1.7
ENV DOTNET_DOWNLOAD_URL https://dotnetcli.blob.core.windows.net/dotnet/preview/Binaries/$DOTNET_VERSION/dotnet-win-x64.$DOTNET_VERSION.zip

RUN Invoke-WebRequest $Env:DOTNET_DOWNLOAD_URL -OutFile dotnet.zip; \
RUN Expand-Archive dotnet.zip -DestinationPath $Env:ProgramFiles\dotnet -Force; \
RUN Remove-Item -Force dotnet.zip
    
# Install .NET Core SDK
ENV DOTNET_VERSION 3.1.7
ENV DOTNET_SDK_DOWNLOAD_URL https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-dev-win-x64.$DOTNET_SDK_VERSION.zip

RUN Invoke-WebRequest $Env:DOTNET_SDK_DOWNLOAD_URL -OutFile dotnet.zip; \
RUN Expand-Archive dotnet.zip -DestinationPath $Env:ProgramFiles\dotnet -Force; \
RUN Remove-Item -Force dotnet.zip

SHELL ["cmd", "/S", "/C"]

RUN setx /M PATH "%PATH%;%ProgramFiles%\dotnet"

# Trigger the population of the local package cache
ENV NUGET_XMLDOC_MODE skip

RUN mkdir C:\warmup \
RUN cd C:\warmup \
RUN dotnet new \
RUN cd .. \
RUN rmdir /S /Q C:\warmup 

#Change Working Directory to Install DevOps Tools
WORKDIR /azp
#Install DevOps Agents
COPY start.ps1 .
#Configure DevOps Agent
CMD powershell .\start.ps1

我今天设法解决了这个令人沮丧的问题,下面是我为下一个人出现这个问题所做的,因为Docker不会很快解决它

我所做的是,在Windows/Mac上的桌面应用程序中,您可以编辑守护程序文件。在Docker应用程序的“Docker引擎”下的“设置”下,我在文件底部的最后一个大括号上方添加了一行<代码>“dns”:[“192.168.4.100”、“8.8.8.8”]

这样,Docker容器就可以使用主机的DNS服务器来容纳您现在构建的所有内容。从技术上讲,如果您可以访问:那么您应该能够访问choco存储库

我还构建了该图像,并在回购协议中对其进行了标记:

microsoft/windowsservercore:10.0.14393.1358

然后,在我的第一个choco安装命令之前设置:
RUN choco feature enable--name allowGlobalConfirmation
,这使choco能够安装所有文件,而不会出错

我的Docker文件运行并构建了图像。在我的测试环境中,现在在我的产品环境中进行测试。:)

帮助我的链接:

请将您的问题标题改为描述您遇到的问题或您提出的问题的标题。您当前的标题只是重复标签中已有的信息,并添加“与的问题”,这没有任何意义或价值。你的标题应该足够清晰和描述性,以便将来的网站用户能够浏览搜索结果列表,寻找解决问题的方法。你目前的头衔不能满足这种需要。谢谢