Dockerfile for .Net Core 3.0 Preview

By James Kenny
1 min read

Table of Contents

I've been moving through .Net Core and working with docker to deploy some real applications. As I've done this I've been collecting different versions of the docker file.

Other posts Dockerfile for .Net Core 2.2 and Docker with .Net Core

.Net Core 3.0 is still in preview as I write this post so this might change, I'll be updating this post as it does and as I find changes.

My version of .net core 3.0 is currently running 3.0.0-preview-19075-0444

FROM microsoft/dotnet:3.0.100-preview2-sdk-alpine3.8 AS build
WORKDIR /app

# copy csproj and restore as distinct layers
COPY *.sln .
COPY Serversncodenetcore3.0_docker/*.*.csproj ./Serversncodenetcore3.0_docker/
RUN dotnet restore

# copy everything else and build app
COPY Serversncodenetcore3.0_docker/. ./Serversncodenetcore3.0_docker/
WORKDIR /app/Serversncodenetcore3.0_docker
RUN dotnet publish -c Release -o out

FROM microsoft/dotnet:3.0.0-preview2-aspnetcore-runtime-alpine3.8  AS runtime
WORKDIR /app
COPY --from=build /app/Serversncodenetcore3.0_docker/out ./
ENTRYPOINT ["dotnet", "Serversncodenetcore3.0_docker.dll"]

For this I used 3.0.100-preview2-sdk-alpine3.8 as my build image

FROM microsoft/dotnet:3.0.100-preview2-sdk-alpine3.8 AS build

For runtime I used 3.0.0-preview2-aspnetcore-runtime-alpine3.8

FROM microsoft/dotnet:3.0.0-preview2-aspnetcore-runtime-alpine3.8  AS runtime

Tagged in:

dotnetcore, Docker

Last Update: September 09, 2019

About the Author