我刚刚在我的简单asp.net核心演示project中添加了一个Dockerfile。
我跑步时
docker build -f .\deploy\Dockerfile -t coreapp .
它产生的图像为1.35GB。
Docker版本(适用于Windows的docker)
Client:
Version: 18.06.1-ce
API version: 1.38
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:21:34 2018
OS/Arch: windows/amd64
Experimental: false
Server:
Engine:
Version: 18.06.1-ce
API version: 1.38 (minimum version 1.24)
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:36:40 2018
OS/Arch: windows/amd64
Experimental: false
Dockerfile
FROM microsoft/dotnet:2.1-sdk AS build-env
WORKDIR /build
COPY . /build
#Restore
RUN dotnet restore ./WebAppDockerDemo.sln
RUN dotnet publish ./src/WebApp/WebApp.csproj --output /publish --configuration Release
# Build runtime image
FROM microsoft/dotnet:2.1-aspnetcore-runtime
WORKDIR /app
COPY --from=build-env /publish/ .
ENTRYPOINT ["dotnet", "WebApp.dll"]
为什么图像这么大?我以为我创建的运行时映像大约为2-300MB。我检查了不同的示例1,但在这里找不到问题所在。
如何减小尺寸?