docker .net core 3.1.5 镜像制作
官方 dockerfile
ARG REPO=mcr.microsoft.com/dotnet/core/runtime FROM $REPO:3.1-buster-slim # Install ASP.NET Core RUN aspnetcore_version=3.1.5 \ && curl -SL --output aspnetcore.tar.gz https://dotnetcli.azureedge.net/dotnet/aspnetcore/Runtime/$aspnetcore_version/aspnetcore-runtime-$aspnetcore_version-linux-x64.tar.gz \ && aspnetcore_sha512='262a8e670a8800aea1c518e48a237543f2bca92010187d25cae2bd513163786c5b49ff2593b1e256ca89201fd3d819c2265f8a3946b257e8490b37a5a66e1fff' \ && echo "$aspnetcore_sha512 aspnetcore.tar.gz" | sha512sum -c - \ && tar -ozxf aspnetcore.tar.gz -C /usr/share/dotnet ./shared/Microsoft.AspNetCore.App \ && rm aspnetcore.tar.gz
官网 dockerfile 地址
最新 .net core 版本查询
https://dotnet.microsoft.com/download/dotnet-core
修改后的 dockerfile 增加web站点
FROM debian:stable-20200607-slim # Install ASP.NET Core RUN set -eux; \ aspnetcore_version=3.1.5; \
apt-get update; \
apt install -y libunwind8 libicu63 libssl1.1; \ savedAptMark="$(apt-mark showmanual)";\ apt-get install -y --no-install-recommends wget; \ wget -nv -O aspnetcore.tar.gz https://dotnetcli.azureedge.net/dotnet/aspnetcore/Runtime/$aspnetcore_version/aspnetcore-runtime-$aspnetcore_version-linux-x64.tar.gz; \ aspnetcore_sha512='262a8e670a8800aea1c518e48a237543f2bca92010187d25cae2bd513163786c5b49ff2593b1e256ca89201fd3d819c2265f8a3946b257e8490b37a5a66e1fff'; \ echo "$aspnetcore_sha512 aspnetcore.tar.gz" | sha512sum -c -; \ mkdir -p /usr/share/dotnet; \ #先创建目录 tar -ozxf aspnetcore.tar.gz -C /usr/share/dotnet; \ #解压到目录 rm aspnetcore.tar.gz; \ ln -s /usr/share/dotnet/dotnet /usr/local/bin; \ #增加软连接 chmod +x /usr/share/dotnet/dotnet; \ apt-mark auto '.*' > /dev/null; \ [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark > /dev/null; \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ rm -rf /var/lib/apt/lists/*; \
dotnet --info; #显示dotnet信息
EXPOSE 80 443 # 导出端口
WORKDIR /website # 设置工作目录
ADD website.tar.gz /website # 添加站点
ENTRYPOINT ["dotnet"]
CMD ["/website/website.dll"] # 参数为站点的主dll