docker / for-win

Bug reports for Docker Desktop for Windows
https://www.docker.com/products/docker#/windows
1.85k stars 286 forks source link

Make Dockerfile Failed on Windows container #427

Closed soymilkfj closed 7 years ago

soymilkfj commented 7 years ago

Hi there, I am new for Docker on Windows 10. I try to make my Dockerfile FROM microsoft/windowsservercore but it had some wrong . Why can't I make new image ?

Expected behavior

Server: Version: 1.13.0 API version: 1.25 (minimum version 1.24) Go version: go1.7.3 Git commit: 49bf474 Built: Wed Jan 18 16:20:26 2017 OS/Arch: windows/amd64 Experimental: true'

PS C:\mydockerbuild> docker info Containers: 5 Running: 0 Paused: 0 Stopped: 5 Images: 4 Server Version: 1.13.0 Storage Driver: windowsfilter Windows: Logging Driver: json-file Plugins: Volume: local Network: l2bridge l2tunnel nat null overlay transparent Swarm: inactive Default Isolation: hyperv Kernel Version: 10.0 14393 (14393.693.amd64fre.rs1_release.161220-1747) Operating System: Windows 10 Pro OSType: windows Architecture: x86_64 CPUs: 4 Total Memory: 7.482 GiB Name: claire-PC ID: CCNQ:ZISQ:IPUR:GETG:LAGY:YOBB:EZ5T:5LR4:45DU:QP4N:5AU6:45JX Docker Root Dir: C:\ProgramData\Docker Debug Mode (client): false Debug Mode (server): true File Descriptors: -1 Goroutines: 18 System Time: 2017-01-25T11:06:21.9981261+08:00 EventsListeners: 0 Username: soymilk Registry: https://index.docker.io/v1/ Experimental: true Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false


### Steps to reproduce the behavior

  1. I use Dockerfile from [this](https://github.com/Microsoft/Virtualization-Documentation/blob/master/windows-container-samples/python/Dockerfile)
  2.  docker build -t="soymilk/python" .
erroinfo 

PS C:\mydockerbuild> docker build -t="soymilk/eastek" . Sending build context to Docker daemon 2.56 kB Step 1/5 : FROM microsoft/windowsservercore ---> 4d83c32ad497 Step 2/5 : LABEL Description "Python" Vendor "Python Software Foundation" Version "3.5.1" ---> Using cache ---> 51914dbdab78 Step 3/5 : RUN powershell.exe -Command $ErrorActionPreference = 'Stop'; wget https://www.python.org/ftp/python/3.5.1/python-3.5.1.exe -OutFile c:\python-3.5.1.exe ; Start-Process c:\pyt hon-3.5.1.exe -ArgumentList '/quiet InstallAllUsers=1 PrependPath=1' -Wait ; Remove-Item c:\python-3.5.1.exe -Force ---> Running in ceee509c9dbb wget : The remote name could not be resolved: 'www.python.org' At line:1 char:34

The command 'cmd /S /C powershell.exe -Command $ErrorActionPreference = 'Stop'; wget https://www.python.org/ftp/python/3.5.1/python-3.5.1.exe -OutFile c:\python-3.5.1.exe ; Start-Proces s c:\python-3.5.1.exe -ArgumentList '/quiet InstallAllUsers=1 PrependPath=1' -Wait ; Remove-Item c:\python-3.5.1.exe -Force' returned a non-zero code: 1

soymilkfj commented 7 years ago

Sorry for my poor English. Can someone give me some suggestions from my problem?

friism commented 7 years ago

It looks like you cannot access https://www.python.org - can you make sure that you have access to that from your container host and that no proxy or similar is getting in the way?

soymilkfj commented 7 years ago

@friism Here is my setting 1485316665630

soymilkfj commented 7 years ago

I also try into microsoft/windowsservercore container. (use > docker run -i -t microsoft/windowsservercore powershell.exe)

PS C:\> wget
cmdlet Invoke-WebRequest at command pipeline position 1
Supply values for the following parameters:
Uri: https://www.python.org/ftp/python/3.5.1/python-3.5.1.exe
wget : The remote name could not be resolved: 'www.python.org'
At line:1 char:1
+ wget
+ ~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
PS C:\> wget
cmdlet Invoke-WebRequest at command pipeline position 1
Supply values for the following parameters:
Uri: https://sourceforge.net/projects/lazarus/files/Lazarus%20Windows%2064%20bits/Lazarus%201.6.2/lazarus-1.6.2-fpc-3.0.0-win64.exe
wget : The remote name could not be resolved: 'sourceforge.net'
At line:1 char:1
+ wget
+ ~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
friism commented 7 years ago

Please try the networking debug script: https://github.com/Microsoft/Virtualization-Documentation/tree/master/windows-server-container-tools/CleanupContainerHostNetworking

soymilkfj commented 7 years ago

@friism I have ran ./CleanupContainerHostNetworking.ps1 and get a file named "PreCleanupState_MVIWKRDA"

Name                : winnat
RequiredServices    : {Tcpip}
CanPauseAndContinue : False
CanShutdown         : False
CanStop             : True
DisplayName         : Windows NAT Driver
DependentServices   : {}
MachineName         : .
ServiceName         : winnat
ServicesDependedOn  : {Tcpip}
ServiceHandle       : SafeServiceHandle
Status              : Running
ServiceType         : KernelDriver
StartType           : Automatic
Site                : 
Container           : 
Store                            : Local
TcpFilteringBehavior             : AddressDependentFiltering
UdpFilteringBehavior             : AddressDependentFiltering
UdpInboundRefresh                : False
Active                           : True
Caption                          : 
Description                      : 
ElementName                      : 
InstanceID                       : Hddae7244-98b8-4290-9712-76880b83d30e;0
ExternalIPInterfaceAddressPrefix : 
IcmpQueryTimeout                 : 30
InternalIPInterfaceAddressPrefix : 172.25.112.1/20
InternalRoutingDomainId          : {00000000-0000-0000-0000-000000000000}
Name                             : Hddae7244-98b8-4290-9712-76880b83d30e
TcpEstablishedConnectionTimeout  : 1800
TcpTransientConnectionTimeout    : 120
UdpIdleSessionTimeout            : 120
PSComputerName                   : 
CimClass                         : root/StandardCimv2:MSFT_NetNat
CimInstanceProperties            : {Caption, Description, ElementName, InstanceID...}
CimSystemProperties              : Microsoft.Management.Infrastructure.CimSystemProperties
Name                                : nat
Id                                  : ed0692bf-9196-4318-906f-a73070c3f1ad
Notes                               : 
Extensions                          : {Microsoft Windows 篩選平台, Microsoft NDIS Capture}
BandwidthReservationMode            : Absolute
PacketDirectEnabled                 : False
EmbeddedTeamingEnabled              : False
IovEnabled                          : False
SwitchType                          : Internal
AllowManagementOS                   : True
NetAdapterInterfaceDescription      : 
NetAdapterInterfaceDescriptions     : 
IovSupport                          : False
IovSupportReasons                   : 
AvailableIPSecSA                    : 0
NumberIPSecSAAllocated              : 0
AvailableVMQueues                   : 0
NumberVmqAllocated                  : 0
IovQueuePairCount                   : 0
IovQueuePairsInUse                  : 0
IovVirtualFunctionCount             : 0
IovVirtualFunctionsInUse            : 0
PacketDirectInUse                   : False
DefaultQueueVrssEnabledRequested    : True
DefaultQueueVrssEnabled             : False
DefaultQueueVmmqEnabledRequested    : False
DefaultQueueVmmqEnabled             : False
DefaultQueueVmmqQueuePairsRequested : 16
DefaultQueueVmmqQueuePairs          : 0
BandwidthPercentage                 : 0
DefaultFlowMinimumBandwidthAbsolute : 0
DefaultFlowMinimumBandwidthWeight   : 0
CimSession                          : CimSession: .
ComputerName                        : CLAIRE-PC
IsDeleted                           : False

Name                                : DockerNAT
Id                                  : 3471f71b-cc7b-43f5-8850-9b8af135865e
Notes                               : 
Extensions                          : {Microsoft Windows 篩選平台, Microsoft NDIS Capture}
BandwidthReservationMode            : Absolute
PacketDirectEnabled                 : False
EmbeddedTeamingEnabled              : False
IovEnabled                          : False
SwitchType                          : Internal
AllowManagementOS                   : True
NetAdapterInterfaceDescription      : 
NetAdapterInterfaceDescriptions     : 
IovSupport                          : False
IovSupportReasons                   : 
AvailableIPSecSA                    : 0
NumberIPSecSAAllocated              : 0
AvailableVMQueues                   : 0
NumberVmqAllocated                  : 0
IovQueuePairCount                   : 0
IovQueuePairsInUse                  : 0
IovVirtualFunctionCount             : 0
IovVirtualFunctionsInUse            : 0
PacketDirectInUse                   : False
DefaultQueueVrssEnabledRequested    : True
DefaultQueueVrssEnabled             : False
DefaultQueueVmmqEnabledRequested    : False
DefaultQueueVmmqEnabled             : False
DefaultQueueVmmqQueuePairsRequested : 16
DefaultQueueVmmqQueuePairs          : 0
BandwidthPercentage                 : 0
DefaultFlowMinimumBandwidthAbsolute : 0
DefaultFlowMinimumBandwidthWeight   : 0
CimSession                          : CimSession: .
ComputerName                        : CLAIRE-PC
IsDeleted                           : False
friism commented 7 years ago

@soymilkfj does it work after the clean-up? Checking with @kallie-b to see if she has ideas

soymilkfj commented 7 years ago

I create a new network on Hyper-V and change from origin It still can't wget . :( But the issues have some different

PS C:\Users\ContainerUser\Desktop> wget

cmdlet Invoke-WebRequest at command pipeline position 1
Supply values for the following parameters:
Uri: https://sourceforge.net/projects/lazarus/files/Lazarus%20Windows%2064%20bits/Lazarus%201.6.2/lazarus-1.6.2-fpc-3.0.0-win64.exe
wget : The response content cannot be parsed because the Internet Explorer engine is not available, or Internet
Explorer's first-launch configuration is not complete. Specify the UseBasicParsing parameter and try again.
At line:1 char:1
+ wget
+ ~~~~
    + CategoryInfo          : NotImplemented: (:) [Invoke-WebRequest], NotSupportedException
    + FullyQualifiedErrorId : WebCmdletIEDomNotSupportedException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
jelster commented 7 years ago

@soymilkfj - I think that's good news because it means that wget was able to make the request and receive a response. In your wget command, add -UseBasicParsing and you'll instead get the response content. All things being equal, it might appear your initial issue may have been resolved since you are receiving data from the external endpoint.

"https://sourceforge.net/projects/lazarus/files/Lazarus%20Windows%2064%20bits/Lazarus%201.6.2/lazarus-1.6.2-fpc-3.0.0-win64.exe wget : The response content cannot be parsed because the Internet Explorer engine is not available, or Internet Explorer's first-launch configuration is not complete. Specify the UseBasicParsing parameter and try again"

Hope this helps!

soymilkfj commented 7 years ago

@jelster I used wget -UseBasicParsing and got this message

PS C:\Users\ContainerUser\Desktop> wget -UseBasicParsing

cmdlet Invoke-WebRequest at command pipeline position 1
Supply values for the following parameters:
Uri: https://www.python.org/ftp/python/3.5.1/python-3.5.1.exe

StatusCode        : 200
StatusDescription : OK
Content           : {77, 90, 144, 0...}
RawContent        : HTTP/1.1 200 OK
                    X-Clacks-Overhead: GNU Terry Pratchett
                    Connection: keep-alive
                    X-Served-By: cache-itm7420-ITM
                    X-Cache: HIT
                    X-Cache-Hits: 0
                    X-Timer: S1486013039.802739,VS0,VE0
                    Public-Key-Pins: ma...
Headers           : {[X-Clacks-Overhead, GNU Terry Pratchett], [Connection, keep-alive], [X-Served-By, cache-itm7420-ITM], [X-Cache, HIT]...}
RawContentLength  : 28743504
Content           : {77, 90, 144, 0...}
RawContent        : HTTP/1.1 200 OK
                    X-Clacks-Overhead: GNU Terry Pratchett
                    Connection: keep-alive
                    X-Served-By: cache-itm7420-ITM
                    X-Cache: HIT
                    X-Clacks-Overhead: GNU Terry Pratchett
                    Connection: keep-alive
                    X-Served-By: cache-itm7420-ITM
                    X-Cache: HIT
                    X-Cache-Hits: 0
                    X-Timer: S1486013039.802739,VS0,VE0
                    Public-Key-Pins: ma...
Headers           : {[X-Clacks-Overhead, GNU Terry Pratchett], [Connection, keep-alive], [X-Served-By, cache-itm7420-ITM], [X-Cache, HIT]...}
RawContentLength  : 28743504

Do I download successfully ?
I can't find the file.

friism commented 7 years ago

@soymilkfj you want to do:

Invoke-WebRequest https://www.python.org/ftp/python/3.5.1/python-3.5.1.exe -UseBasicParsing -OutFile python-3.5.1.exe
fcatae commented 7 years ago

I just ran into this problem in which the name resolution wasn't working properly.  Solution: I configured daemon.json (at c:\programdata\docker\config) to use the DNS server 8.8.8.8. The daemon.json parameters are described here: https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/configure-docker-daemon Hope it helps.

kallie-b commented 7 years ago

Apologies, until now I missed that I was pinged on this thread.

@soymilkfj -- can you update me on where you are now with this issue?

Also when you ran the ./CleanupContainerHostNetworking.ps1 script, did you do so with the -CaptureTraces argument? If you run the script with that argument the script should "hang" and ask you to repro your issue. Then once you've done that, you stop the script by pressing enter. When the script is stopped it will create a "PostCleanupState_XXXXXX" folder long with the "PreCleanupState_XXXXXX" folder.

Once you've done this, you're welcome to send the resulting files to our team and we'll help you troubleshoot this. Just zip the files and send them to: sdn_feedback@microsoft.com

soymilkfj commented 7 years ago

@kallie-b OK I will send the e-mail. @friism I used and got a python-3.5.1.exe

simonferquel commented 7 years ago

I suppose the issue is fixed then. Closing the issue (feel free to have a direct followup with @kallie-b)

akitchin commented 7 years ago

I believe this is still an issue, I downloaded the Docker Community Edition 17.03.0-ce-win1 (10300) and even though the host was able to download files correctly. I had to go to View Network Connections, vEthernal (HNS Internal Nic) -> Internet Protocol Version 4 -> Properties -> Explicitly set dns to 8.8.8.8. before building an image that includes Wget/

kallie-b commented 7 years ago

So, containers that you're creating on Windows 10 don't automatically have access to the internet? Is the symptom of the issue that you wouldn't be able to run something like WebRequest https://www.python.org/ftp/python/3.5.1/python-3.5.1.exe -UseBasicParsing -OutFile python-3.5.1.exe from within a container?

vargur88 commented 7 years ago

True. The exact issue is still present. Even explicit setting of DNS do not solve the problem.

jelster commented 7 years ago

FWIW, using Version 17.04.0-ce-rc2-win6 (10840) running on Win 10 v1607 (build 14393.969) I just ran docker run --rm -ti microsoft/windowsservercore:latest powershell "wget http://google.com -useBasicParsing" with no issues. Here's the values from running docker network inspect nat:

[
    {
        "Name": "nat",
        "Id": "<snip>",
        "Created": "2017-04-03T13:59:31.5106682-05:00",
        "Scope": "local",
        "Driver": "nat",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "windows",
            "Options": null,
            "Config": [
                {
                    "Subnet": "0.0.0.0/0",
                    "Gateway": "0.0.0.0"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Containers": {},
        "Options": {
            "com.docker.network.windowsshim.hnsid": "<snip>",
            "com.docker.network.windowsshim.networkname": "nat"
        },
        "Labels": {}
    }
]

To make sure it wasn't a fluke, I changed the URL to docker.com; the name was still resolved (though you'll get a request aborted exception since this wget wasn't configured to follow redirects/change protocols to HTTPS).

vargur88 commented 7 years ago

Thx for assist! Take a look on my output please:

wget : The remote name could not be resolved: 'google.com' At line:1 char:1

Update: My output for docker network inspect nat makes all clear:

"IPAM": {"Driver": "windows", "Options": null, "Config": [ { "Subnet": "172.29.96.0/20", "Gateway": "172.29.96.1" }]}

kallie-b commented 7 years ago

Let's try recreating your default NAT network.

Stop-Service docker
Get-ContainerNetwork | Remove-ContainerNetwork -Force
Start-Service docker

After running the above commands, could you show us the output of docker network inspect nat again?

vargur88 commented 7 years ago

Ok, remove operation performed well. Here it is new output:

[
    {
        "Name": "nat",
        "Id": "52bc20069d52c09b5e3f80d0081d147a4572984b3e8876280d69f6787489c97c",
        "Created": "2017-04-06T11:07:46.6376652+03:00",
        "Scope": "local",
        "Driver": "nat",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "windows",
            "Options": null,
            "Config": [
                {
                    "Subnet": "0.0.0.0/0",
                    "Gateway": "0.0.0.0"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Containers": {},
        "Options": {
            "com.docker.network.windowsshim.hnsid": "b398d7ab-1186-4aa0-ae22-89aa7cf280ba",
            "com.docker.network.windowsshim.networkname": "nat"
        },
        "Labels": {}
    }
]

But I still have name resolving issue.

kallie-b commented 7 years ago

@vargur88

Can you run ipconfig /all from within the container itself and report the results?

Also, from within the container run ping www.bing.com and nslookup www.bing.com so that we can see exactly which responses you're getting.

fcatae commented 7 years ago

I got this fixed in 2 steps:

  1. Configure daemon.json (at c:\programdata\docker\config) to use the DNS server 8.8.8.8. The daemon.json parameters are described here: https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/configure-docker-daemon

  2. Add this line in Dockerfile: RUN Set-ItemProperty -path 'HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters' -Name ServerPriorityTimeLimit -Value 0 -Type DWord Ref: https://github.com/docker/docker/issues/27499

robe070 commented 7 years ago

@kallie-b This is issue is still occurring on the latest microsoft/mssql-server-windows image id 7f4a5f7b843c. The host is Windows Server 2016 with Container support The issue occurs when the host, a virtual machine, is stopped externally. That is, its not a clean shutdown. If I run

Stop-Service docker
Get-ContainerNetwork | Remove-ContainerNetwork -Force
Start-Service docker

It fixes it.

When the VM is shutdown from within the VM the network works correctly.

akalankapagoda commented 5 years ago

@kallie-b This is issue is still occurring on the latest microsoft/mssql-server-windows image id 7f4a5f7b843c. The host is Windows Server 2016 with Container support The issue occurs when the host, a virtual machine, is stopped externally. That is, its not a clean shutdown. If I run

Stop-Service docker
Get-ContainerNetwork | Remove-ContainerNetwork -Force
Start-Service docker

It fixes it.

When the VM is shutdown from within the VM the network works correctly.

Came here to say that this is still the solution in 2019.

thesuavehog commented 4 years ago

In case anyone else runs into this (as I just did)...

I had to:

  1. Control Panel > Network and Internet > Network Connections
  2. vEthernet (Default Switch) > Properties
  3. Internet Protocol Version 4 (TCP/IPv4) > Properties
  4. Set DNS server to 8.8.8.8
  5. docker build --network "Default Switch" -

Note: WindowsContainerNetworking-LoggingAndCleanupAide.ps1 did not fix things for me. It didn't even pause in the reproduction step.

man, getting docker building on Windows 10 has been annoying...

ashayakc commented 4 years ago

I just ran into this problem in which the name resolution wasn't working properly.  Solution: I configured daemon.json (at c:\programdata\docker\config) to use the DNS server 8.8.8.8. The daemon.json parameters are described here: https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/configure-docker-daemon Hope it helps.

worked for me thanks

temmyg commented 4 years ago

https://github.com/docker/for-win/issues/2760 this post solved my issue:

This often happens when there are multiple networking adapters (Ethernet, Wi-Fi, etc.) present on the host. The priority of these adapters needs to be configured properly in order for the Windows networking stack to correctly choose gateway routes. You can fix this by setting your primary internet-connected networking adapter to have the lowest InterfaceMetric value. Try these Powershell commands from an elevated console:

Get-NetIPInterface -AddressFamily IPv4 | Sort-Object -Property InterfaceMetric -Descending

Again, you want your host's primary internet-connected network adapter to have the lowest InterfaceMetric value.

Use this command to make the change (example assumes primary adapter InterfaceAlias is 'Wi-Fi'):

Set-NetIPInterface -InterfaceAlias 'Wi-Fi' -InterfaceMetric 3

That should do it. If your host's primary network adapter is bridged because you have an External virtual switch setup in Hyper-V, then you will set the external virtual switch to have the lowest InterfaceMetric value.

You can verify your routing tables by using this command (the last line should show the primary adapter's gateway address along with it's ifMetric value):

Get-NetRoute -AddressFamily IPv4

I hope this helps!

docker-robott commented 4 years ago

Closed issues are locked after 30 days of inactivity. This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. /lifecycle locked