Warm-up: Build a .net core console app13 Jul 2020 | CSharp-ASP.NET Core
Docker is a container technique, which is lightweight and convenient, and it has become a massively popular technology. What are you waiting for, let’s explore it together!
This article will show you a simple, which you can learn how to build a .net Core Console application in Docker step by step.
Build and Publish a console App
You can choose different editors, like VSCode, Visual Studio, etc. This article builds an App through the command-line interface. Make sure you have .NET CORE SDK installed first.
Use the following snippet to create a .NET Core app.
MyApp folder, then run your App.
Publish your App.
Get into your released folder, then run your
.dll file up.
Dockerfile with the following snippet to containerize your released App.
Put the above Dockerfile under
Build an image.
Run your image as container.
Now, your container is running up successfully. If you want to extend more, check the Docker.
The above process only containerized your released App. As the Docker is a container, so you can do the same thing as you are in a real operating system. You can build, publish, release your App in a single Docker container. Even though you can do multi-steps in a single docker container, however, it is not recommended. It will be hard to manage and track stages when doing too many steps in a single docker container. You can take advantage of the multi-stage feature, which is much more flexible and convenient.
The following Dockerfile illustrate a multi-stage example in a single Dockerfile.
The above Dockerfile comes from Visual Studio Docker Tools, and the above Dockerfile related to
multistage features, which was introduced in docker 17.05. Check these articles How Visual Studio builds containerized apps, and Use multi-stage builds to learn more about Docker and Visual Studio.
-f to specify the Dockerfile explicitly.
Through this tutorial, you’ve learned how to deploy NET CORE Console in Docker. Take a look review.
- Docker is a container, which provides all the necessary packages you need. You can configure your App to be built, run, release in a single Dockerfile(use the
- Visual Studio Docker Support Tools takes the advantages of the Docker’s
- If you want to learn more about Docker, see Docker Tutorial.