14

I'm trying to create a new docker image with the following dockerfile, but it's taking an awful long time to finish one of the steps:

FROM microsoft/dotnet-framework:4.7

SHELL ["powershell"]

# Note: Get MSBuild 12.
RUN Invoke-WebRequest "https://download.microsoft.com/download/9/B/B/9BB1309E-1A8F-4A47-A6C5-ECF76672A3B3/BuildTools_Full.exe" -OutFile "$env:TEMP\BuildTools_Full.exe" -UseBasicParsing
RUN &  "$env:TEMP\BuildTools_Full.exe" /Silent /Full
# Todo: delete the BuildTools_Full.exe file in this layer

# Note: Add .NET 
## RUN Install-WindowsFeature NET-Framework-45-Features ; \

# Note: Add NuGet
RUN Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile "C:\windows\nuget.exe" -UseBasicParsing
WORKDIR "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0"

# Note: Add Msbuild to path
RUN setx PATH '%PATH%;C:\\Program Files (x86)\\MSBuild\\12.0\\Bin\\msbuild.exe'
CMD ["C:\\Program Files (x86)\\MSBuild\\12.0\\Bin\\msbuild.exe"]

Here is the output so far:

PS C:\MyWorkspace\images\msbuild> docker build -t msbuild .
Sending build context to Docker daemon   2.56kB
Step 1/9 : FROM microsoft/dotnet-framework:4.7
 ---> 91abbfdc50cb
Step 2/9 : MAINTAINER mohamed.elkammar@gmail.com
 ---> Using cache
 ---> fbf720101007
Step 3/9 : SHELL powershell
 ---> Using cache
 ---> 642cf0e08730
Step 4/9 : RUN Invoke-WebRequest "https://download.microsoft.com/download/9/B/B/9BB1309E-1A8F-4A47-A6C5-ECF76672A3B3/BuildTools_Full.exe" -OutFile "$env:TEMP\BuildTools_Full.exe" -UseBasicParsing
 ---> Using cache
 ---> a722c88fee0f
Step 5/9 : RUN &  "$env:TEMP\BuildTools_Full.exe" /Silent /Full
 ---> Using cache
 ---> 4fda7448f2e4
Step 6/9 : RUN Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile "C:\windows\nuget.exe" -UseBasicParsing
 ---> Running in eec036874574

Additionally, here is the output of docker info:

C:\Windows\system32>docker info
Containers: 2
 Running: 1
 Paused: 0
 Stopped: 1
Images: 5
Server Version: 17.06.1-ee-2
Storage Driver: windowsfilter
 Windows:
Logging Driver: json-file
Plugins:
 Volume: local
 Network: l2bridge l2tunnel nat null overlay transparent
 Log: awslogs etwlogs fluentd json-file logentries splunk syslog
Swarm: inactive
Default Isolation: process
Kernel Version: 10.0 14393 (14393.1715.amd64fre.rs1_release_inmarket.170906-1810)
Operating System: Windows Server 2016 Datacenter
OSType: windows
Architecture: x86_64
CPUs: 1
Total Memory: 4.75GiB
Name: instance-1
ID: B2BG:6AW5:Y32S:YLIO:FE25:WWDO:ZAGQ:CZ3M:S5XM:LSHB:U5GM:VYEM
Docker Root Dir: C:\ProgramData\docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

What would cause a simple download step to take forever?

mbadawi23
  • 1,029
  • 2
  • 21
  • 43
  • 4
    I have the same issue, did you discovered anything? – Alberto Monteiro Dec 13 '17 at 13:59
  • Is your problem with nuget as well? – mbadawi23 Dec 13 '17 at 15:37
  • No, I just run a dotnet-framework image interactivity on powershell, and I have to wait about 40 seconds to container start – Alberto Monteiro Dec 13 '17 at 16:19
  • I have to wait ridiculous amount of time. If your issue is that you need to wait for the task to finish, try using `| Out-Null` after your command. – mbadawi23 Dec 13 '17 at 17:13
  • I am just running this: `docker run -it microsoft/dotnet-framework` – Alberto Monteiro Dec 13 '17 at 17:40
  • I used to get this with browserify running under node but fixed it by increasing the amount of memory allocated to docker in the configuration. Might be worth a try. – Richie Mackay Jan 22 '18 at 10:52
  • Really guys... switch to Linux. Jokes aside, even on Linux docker can be slow - usually it's a problem with the storage driver. Not sure if there is a choice in Windows. You can run MSSQL and Dotnet on Linux nowadays. – dagelf Jun 26 '18 at 23:32
  • The application I work on is cannot be run on Mono and it is strongly tied to windows because of other dependencies, some can be isolated, and cannot. What do you mean by a problem with the _storage driver_? – mbadawi23 Jun 28 '18 at 23:41
  • are you using docker desktop? have you configured windows containers and nto linux ones i assume? If not change to windows containers? Also as @blake mentioned below, first time run or pull takes a long time to cache, but further runs must be faster – Srini M Nov 25 '19 at 06:32

2 Answers2

1

I had face a similar issue with Docker and Windows. Tried the following options:

  1. Check if DNS is too slow. I replaced few nameserver entries in /etc/resolve.conf with 8.8.8.8 and did a force-reload. This helped reduce the load time.

  2. Check if docker is connecting to dockerd through IPv6; which is in my case wasn't the listener. Disabling IPv6 on network interfaces and rebooting the machine helped reduce the load time.

VAT
  • 170
  • 2
  • 4
  • 20
0

A docker build process will take quite a bit longer than running a container. It also depends on docker has cached.

So usually the first time a container is build when there is no cache it takes the longest, then subsequent docker builds the Docker Engine will use its cache if available. When you run a container it is faster once built.

When you build especially the first time docker will pull microsoft/dotnet-framework:4.7 from the public registry unless a copy is already pulled and available locally in docker images. If it is the Docker Engine will use it, if not it will put it from remote repository. If you have a local copy it is faster. You can pull it before the build if you wish or put it maybe in a local private registry and change your tag to your registry url.

Which step exactly is slow? The very last one where it is getting that nuget.exe? If so the first thing that comes to mind maybe is name resolution, DNS, firewalls, or network time outs reaching the internet.

Try to run this container to check name resolution, and see if it can get that file quickly.

FROM centos

MAINTAINER Blake Russo

RUN yum install -y dig wget bind-utils nc ; dig -x dist.nuget.org; nslookup dist.nuget.org; wget dist.nuget.org/win-x86-commandline/latest/nuget.exe; ls -la nug*;

Blake Russo
  • 181
  • 1
  • 9