.NET Core Runtime Image on Docker
Let’s try dotnet sample application within a docker container.
1
docker run microsoft/dotnet-samples
If we have a working docker, we can build our image. First, we will create a dotnet console application;
1
2
3
4
5
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;
1
2
3
4
FROM microsoft/dotnet:runtime
WORKDIR /dotnetapp
COPY out .
ENTRYPOINT ["dotnet", "dotnetapp.dll"]
Now, we can build the image and run it.
1
2
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.
1
docker images -a
This post is licensed under CC BY 4.0 by the author.