。
我正在遵循本指南,以在Docker容器中构建我的.NET 6应用程序:
https://stackify.com/a-start-toart-toart-finish-guide-to-docker-for-net/
使用以下dockerfile:
FROM mcr.microsoft.com/dotnet/core/sdk:6.0 AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:6.0
WORKDIR /app
COPY --from=build-env /app/out .
EXPOSE 80
ENTRYPOINT ["dotnet", "/app/docker-guide.dll"]
我发现这需要很长时间,并且消耗了大量的RAM记忆。
我正在Windows 11上使用Docker桌面。
如何在Docker容器中正确构建它?
I'm following this guide to build my .NET 6 application inside a docker container:
https://stackify.com/a-start-to-finish-guide-to-docker-for-net/
Using the following Dockerfile:
FROM mcr.microsoft.com/dotnet/core/sdk:6.0 AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:6.0
WORKDIR /app
COPY --from=build-env /app/out .
EXPOSE 80
ENTRYPOINT ["dotnet", "/app/docker-guide.dll"]
I discovered it takes a long time and consumes a huge ammount of RAM memory.
I'm using Docker Desktop at Windows 11.
How can I build it correctly inside a docker container?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一段时间后,我发现这与在Dotnet Restore上使用的代理有关。
我在Dotnet还原之前添加:
问题已经解决,现在该建筑物的运作速度更快,并且有合理的RAM。
After some time I found that it has something to do with the proxy being used at dotnet restore.
I added before dotnet restore:
And the problem was solved, now the building is working faster and with a reasonable ammount of RAM.