A Clockwork Engineer

.NET Core Runtime Image on Docker

Let’s try dotnet sample application within a docker container.

docker run microsoft/dotnet-samples


If we have a working docker, we can build our image. First, we will create a dotnet console application;

mkdir dotnetapp
cd dotnetapp
dotnet new console
dotnet restore
dotnet publish -c Release -o out


We need a Dockerfile to declare the dependency on a .NET Core runtime image for our application. It will be like this;

FROM microsoft/dotnet:runtime
WORKDIR /dotnetapp
COPY out .
ENTRYPOINT ["dotnet", "dotnetapp.dll"]

Now, we can build the image and run it.

docker build -t dotnetapp .
docker run -it --rm dotnetapp


We have a result message “Hello World!” printed out on the console and we can see our image installed in docker images list.

docker images -a
docker, dotnet, .NET Core Software

Author: Olcay Bayram

A software enthusiast; currently a Senior Software Engineer of a global retail company, based in Amsterdam. Apart from the BSc, he holds a masters in IT.