-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue while building Docker with ASP.Net - dotnet restore failing #4503
Comments
I think the problem is that you are copying the source to the root directory. That always works poorly. Try applying this pattern: https://github.com/dotnet/dotnet-docker/blob/main/samples/aspnetapp/Dockerfile Also, the |
Hi @richlander , |
Hi, I met a problem that it stocked at "dotnet restore" process when I use docker build. I use MBP with Net7 in visual studio. Use docker build to build my image. I tried the dockerfile from @richlander. It still stocked. it just take half hour to do dotnet restore during docker build process then consume all memory and throw error 137. Does anyone experience this problem before? Thanks for your help! |
Can you share the docker command you are using? |
This seems to be a relatively consistent problem for me. I've tried building on my MBP M2 and my Windows 11 PC with no difference. It's always dotnet restore that's stuck forever. One of my Dockerfiles look like this FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
USER $APP_UID
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
# Add GitHub NuGet sources
ARG GITHUB_NUGET_USERNAME
ARG GITHUB_NUGET_PASSWORD
RUN dotnet nuget add source --username ${GITHUB_NUGET_USERNAME} --password ${GITHUB_NUGET_PASSWORD} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/my-company/index.json"
COPY ["MyProject/MyProject.csproj", "MyProject/"]
COPY ["Directory.Build.props", "Directory.Build.props"]
COPY ["Directory.Packages.props", "Directory.Packages.props"]
COPY ["NuGet.Config", "NuGet.Config"]
RUN dotnet restore "MyProject/MyProject.csproj"
COPY . .
WORKDIR "/src/MyProject"
RUN dotnet build "MyProject.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "MyProject.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyProject.dll"] My build command is
|
hi,
I'm running into issues trying to build a simple Docker container for my ASP.NET app. The build fails at the
docker restore
step with the following message:Property reassignment: $(BaseIntermediateOutputPath)="//obj\" (previous value: "obj\") at /usr/share/dotnet/sdk/7.0.202/Sdks/Microsoft.NET.Sdk.Publish/targets/Microsoft.NET.Sdk.Publish.targets (80,5)
executor failed running [/bin/sh -c dotnet restore -v diagnostic --disable-parallel]: exit code: 137
Even though the error code 137 is often associated to running out of memory based on the issues I found only, that hypothesis looks weird since I've bumped my Docker engine RAM and run the build with 8Gb of ram
docker build -t sched-assignation-backend -f Dockerfile . --memory="8g" --no-cache
Somehow, this issue feels related to issues like this one where the
BaseIntermediateOutputPath
need to be set correctly. Setting its value to "//obj/" looks weird in the error message above, but I'm too new to .Net to say this for sure...Below is my Dockerfile:
.csproj file:
Project file structure:
docker version:
docker info:
Thanks in advance for your help!
Kevan
The text was updated successfully, but these errors were encountered: