Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.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
在docker容器中运行巧克力失败_Docker_Windows Server 2016_Chocolatey - Fatal编程技术网

在docker容器中运行巧克力失败

在docker容器中运行巧克力失败,docker,windows-server-2016,chocolatey,Docker,Windows Server 2016,Chocolatey,我在windows server 2016上安装了docker。Dockerfile包含一些通过Chocolate安装的构建工具。每当我试图从提到的Dockerfile构建映像时,它都会失败。巧克力工具未在容器中运行 # Use the latest Windows Server Core image. FROM microsoft/windowsservercore ENV chocolateyUseWindowsCompression false RUN powershell -Com

我在windows server 2016上安装了docker。Dockerfile包含一些通过Chocolate安装的构建工具。每当我试图从提到的Dockerfile构建映像时,它都会失败。巧克力工具未在容器中运行

# Use the latest Windows Server Core image. 
FROM microsoft/windowsservercore

ENV chocolateyUseWindowsCompression false

RUN powershell -Command \
        iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')); \
        choco feature disable --name showDownloadProgress

RUN choco install visualstudio2015professional 
RUN choco install qtcreator 
RUN choco install curl 
RUN choco install jq 
RUN choco install 7zip.install 
RUN choco install jfrog-cli 
RUN choco install jom

Build command here.........
    C:\Program Files\Docker>docker build -t test -f Dockerfile.txt .
    Sending build context to Docker daemon  54.73MB
    Step 1/10 : FROM microsoft/windowsservercore
    latest: Pulling from microsoft/windowsservercore
    3889bb8d808b: Pull complete
    fb1ebf2c42b6: Pull complete
    Digest: sha256:750440935dd3ef8ea148a8e4f83a0397540a8014938ae7b59eb78211da1d5969
    Status: Downloaded newer image for microsoft/windowsservercore:latest
     ---> 7d89a4baf66c
    Step 2/10 : ENV chocolateyUseWindowsCompression false
     ---> Running in 8a7b1fc97da5
     ---> 0f3c89daf01c
    Removing intermediate container 8a7b1fc97da5
    Step 3/10 : RUN powershell -Command     iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'));     choco feature disable --name showDownloadProgress
     ---> Running in f7088454db37
    Exception calling "DownloadString" with "1" argument(s): "Unable to connect to
    the remote server"
    At line:1 char:1
    + iex ((new-object net.webclient).DownloadString('https://chocolatey.or ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : WebException

    choco : The term 'choco' is not recognized as the name of a cmdlet, function,
    script file, or operable program. Check the spelling of the name, or if a path
    was included, verify that the path is correct and try again.
    At line:1 char:88
    + ... .DownloadString('https://chocolatey.org/install.ps1')); choco feature ...
    +                                                             ~~~~~
        + CategoryInfo          : ObjectNotFound: (choco:String) [], CommandNotFou
       ndException
        + FullyQualifiedErrorId : CommandNotFoundException

    The command 'cmd /S /C powershell -Command     iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'));     choco feature disable --name showDownloadProgress' returned a non-zero code: 1

密钥位于错误消息中:

“无法连接到远程服务器”


您的Docker容器没有internet连接,无法下载Chocolate安装脚本。

对于我来说,这是我的防病毒软件,特别是Symantec,在我的情况下,它一被禁用就开始工作。

您从


这里最接近的问题是:

我刚才有这个问题。它摧毁了我一段时间,我不明白为什么我有一个码头工人的形象是建立良好的,而下一个不是

最后,我发现了一个限制TLS的问题,即较新的Windows docker基本映像需要TLS1.2,而默认情况下,TLS1.2未启用。您的windows server core基本容器可能会遇到这种情况

巧克力文档在关于巧克力的章节中提到了这种情况

他们在写这篇文章时的解决办法是在把它们放回去之前,用TLS设置做一个小音乐椅——见下文

$securityProtocolSettingsOriginal = [System.Net.ServicePointManager]::SecurityProtocol

try {
  # Set TLS 1.2 (3072), then TLS 1.1 (768), then TLS 1.0 (192), finally SSL 3.0 (48)
  # Use integers because the enumeration values for TLS 1.2 and TLS 1.1 won't
  # exist in .NET 4.0, even though they are addressable if .NET 4.5+ is
  # installed (.NET 4.5 is an in-place upgrade).
  [System.Net.ServicePointManager]::SecurityProtocol = 3072 -bor 768 -bor 192 -bor 48
} catch {

  Write-Warning 'Unable to set PowerShell to use TLS 1.2 and TLS 1.1 due to old .NET Framework installed. If you see underlying connection closed or trust errors, you may need to do one or more of the following: (1) upgrade to .NET Framework 4.5 and PowerShell v3, (2) specify internal Chocolatey package location (set $env:chocolateyDownloadUrl prior to install or host the package internally), (3) use the Download + PowerShell method of install. See https://chocolatey.org/install for all install options.'
}

iex ((New-Object 
System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

[System.Net.ServicePointManager]::SecurityProtocol = $securityProtocolSettingsOriginal

否则,使用
docker run--name mycontainer-d[您的容器id]在没有choco的情况下运行您的容器
然后使用docker exec-it mycontainer powershell使用交互式shell,您将能够以交互方式运行choco安装,以获取有关故障的更多信息。

我在具有代理设置的公司网络中从web安装了choco

第一步是创建一个代理.ps1

$ProxyAddress = "http://proxy:port"
[system.net.webrequest]::defaultwebproxy = New-Object system.net.webproxy($ProxyAddress)
$CredCache = [System.Net.CredentialCache]::new()
$NetCreds = [System.Net.NetworkCredential]::new("username","password","")
$CredCache.Add($ProxyAddress, "Basic", $NetCreds)
[system.net.webrequest]::defaultwebproxy.credentials = $CredCache
[system.net.webrequest]::defaultwebproxy.BypassProxyOnLocal = $true
然后在Dockfile中,按以下方式操作:

FROM mcr.microsoft.com/windows:1809-amd64 AS base
SHELL ["cmd", "/S", "/C"]

# add proxy to powershell profile for all users
ADD proxy.ps1 C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
# Install Chocolatey
RUN powershell -ExecutionPolicy unrestricted -Command `
    iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

当我从docker hub或windowsservicecore图像中提取其他图像(例如hello world)时,它起作用了。我已经设置了代理设置。是否有docker命令来验证internet连接的状态?
FROM mcr.microsoft.com/windows:1809-amd64 AS base
SHELL ["cmd", "/S", "/C"]

# add proxy to powershell profile for all users
ADD proxy.ps1 C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
# Install Chocolatey
RUN powershell -ExecutionPolicy unrestricted -Command `
    iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))