-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
.NET6 docker build stuck on dotnet restore #3338
Comments
[Triage] The issue is with this part of the csproj: Because the project is being placed in a directory that is directly under the root of the container, this path causes a scan of the entire container's file system. This slows things down tremendously. One way to workaround this is to not have the RUN dotnet restore /p:IsDockerBuild=true And then modifying your project file to conditionally enable the <Watch Include="..\**\*.env" Condition=" '$(IsDockerBuild)' != 'true' " /> |
Thanks, that solved my issue, I used
|
I had considered the use of |
What is the problem? Is the build hanging at that point? |
Same issue as @NurulloSulaymonov, just get's stuck with .net 7 I enabled -v diag on dotnet restore but nothing happens, |
Any chance you are doing this on an Apple M1 machine? |
I am building this on a M1, but I issued a platform flag for linux/amd64 which this will ultimately will run on.
|
That's the problem. .NET doesn't support QEMU. More context: #3848 |
Thanks for linking the discussion however I am using the Workaround 1 as mentioned in the discussion. I added |
seems the problem is |
It looks like that worked with .NET 6 but not .NET 7. I'll have to update that. |
This happens to me only when I add |
You can use workaround 2 in the doc I linked to. It is the same approach that was used at dotnet/aspnetcore#46306 |
Hmm. I tried Workaround 2 and getting the same result. I removed the --platfrom linx/amd64 from the command line, but the process get's stuck on dotnet restore command. This is my Dockerfile
|
I think I gave some bad advice, sadly. I'll get back to you on Monday with clearer guidance. I misunderstood an aspect of how Docker works. |
FYI: #4388 (comment) |
This seems to be an ongoing problem, why is the issue closed? |
+1 same issue here on Apple M1, dotnet7.0 SDK, trying to build and run on Apple M1 (+ I need single file, self contained and cant use bullseye-slim, doing all of this to test TieredPGO=true and other JIT optimizations). I get to bypass some problems by specifying the RID as
My images (dockerfile is) are: FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
...
FROM mcr.microsoft.com/dotnet/runtime-deps:7.0-alpine
...
ENTRYPOINT exec ./MyApp Other combinations just get stuck at |
@vmandic Your issue is different I think, and is because .Net SDK < 7.0.3 build environment has some issues on apple silicon and a problem with QEMU. Specifically it will hang on restore. The solution is to wait for .Net SDK v 7.0.3 to be released, or to target .Net 8 Preview in your Dockerfile Relevant blog post: https://devblogs.microsoft.com/dotnet/improving-multiplatform-container-support/ There is unfortunately a whole rash of closed github issues that only link to closed github issues to track the problem.... |
I tried with 8.0 preview, still hangs on FROM mcr.microsoft.com/dotnet/nightly/sdk:8.0.100-preview.6-bookworm-slim-amd64 AS build
# Install make
RUN apt-get update && \
apt-get install -y make build-essential libc6-dev
# Run building script
ENTRYPOINT [ "/backend/entrypoint.sh" ] Also tried But |
I have the same problem on Windows 10 Pro. |
I add in the Dockerfile the instruction |
+1 why was this closed as there's no clear solution to the 'restore hanging' issue. |
Can a maintainer please re-open this issue? It's still occurring, even in the .NET 8 release candidate image. |
[Triage] This issue is about disabling dotnet Watch for Docker builds and was resolved with #3338 (comment). If you are having restore issues in scenarios unrelated to dotnet watch, please open a new issue with detailed repro steps. |
Still got problem about restoring nugets on .net 7 in linux/alpine docker system. |
Does your scenario involve dornet-watch? If not please open a new issue with steps to reproduce the issue. TIA. |
I was also getting stuck on dotnet restore with .NET 8. This fixed it immediately, thanks for your comment! |
@MattMckenzy Do you have a working example? Tried different configurations of Dockerfile and none of them seems to work. |
@lbanchero and @sairohith-vanna, I'm on an apple macbook and and I have to add the following environment variable in my ENV DOTNET_EnableWriteXorExecute=0 This works for me but makes the container a bit less responsive. See here for the full |
None of the suggested fixes work here. With the environment variables, the build crashes. Any sample with WORKDIR. ? |
Can you elaborate on the question? |
In a previous comment, it was mentioned that adding the WORKDIR instruction solved the problem. dotnet 8 |
Yes. That's this issue: dotnet/sdk#38050 |
if you're getting this issue with M-chip Mac's, then this is what solved it for me, adding the --platform$BUILDPLATFORM command to ensure that it got the right processor type
|
Describe the Bug
I'm trying to create a docker image of a .NET 6 project, but is stuck during
dotnet restore
while using+12GB
of RAM.My project structure is:
Where I just
cd
in thebackend/
and rundocker build .
This is the output of the console currently:
My csproj:
This is my Dockerfile:
My net usage:

This is a pass result (1 hour) building:

Steps to Reproduce
Clone https://github.com/Neo-Ciber94/ISO810_ERP
And run
cd backend && docker build -f Dockerfile.server .
Other Information
Output of
docker version
Client:
Cloud integration: v1.0.22
Version: 20.10.11
API version: 1.41
Go version: go1.16.10
Git commit: dea9396
Built: Thu Nov 18 00:42:51 2021
OS/Arch: windows/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.11
API version: 1.41 (minimum version 1.12)
Go version: go1.16.9
Git commit: 847da18
Built: Thu Nov 18 00:35:39 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.12
GitCommit: 7b11cfaabd73bb80907dd23182b9347b4245eb5d
runc:
Version: 1.0.2
GitCommit: v1.0.2-0-g52b36a2
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Output of
docker info
Client:
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc., v0.7.1)
compose: Docker Compose (Docker Inc., v2.2.1)
scan: Docker Scan (Docker Inc., 0.9.0)
Server:
Containers: 1
Running: 1
Paused: 0
Stopped: 0
Images: 2
Server Version: 20.10.11
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runtime.v1.linux runc io.containerd.runc.v2
Default Runtime: runc
Init Binary: docker-init
containerd version: 7b11cfaabd73bb80907dd23182b9347b4245eb5d
runc version: v1.0.2-0-g52b36a2
init version: de40ad0
Security Options:
seccomp
Profile: default
Kernel Version: 5.10.16.3-microsoft-standard-WSL2
Operating System: Docker Desktop
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 12.39GiB
Name: docker-desktop
ID: U5CE:U4D3:OMG7:YPA5:TNN5:L6IO:CRVZ:CYE4:Y3TN:7WEM:KSQV:XTS6
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support
The text was updated successfully, but these errors were encountered: