

The -f switch is the path to the Dockerfile. in the docker build command sets the build context of the image. ĭocker will process each line in the Dockerfile. Some of the deeper-level files and folders have been omitted to save space in the article: 📁 docker-workingįrom your terminal, run the following command: docker build -t counter-image -f Dockerfile.

The directory structure of the working folder should look like the following. NET 6.0 SDK and the base image referred to in the Dockerfile is tagged with 6.0. For example, the app created in the previous section used the. Make sure that you pull the runtime version that matches the runtime targeted by your SDK. The image is tagged with 6.0, which is used for versioning. The dotnet segment is the container repository, whereas the sdk or aspnet segment is the container image name. The Microsoft Container Registry (MCR, ) is a syndicate of Docker Hub - which hosts publicly accessible containers. The FROM keyword requires a fully qualified Docker container image name. The ASP.NET Core runtime image is used intentionally here, although the /dotnet/runtime:6.0 image could have been used. FROM /dotnet/sdk:6.0 AS build-envĮNTRYPOINT NET runtime image) and corresponds with the. This tutorial will use the ASP.NET Core runtime image (which contains the. This file is a text file named Dockerfile that doesn't have an extension.Ĭreate a file named Dockerfile in the directory containing the. The Dockerfile file is used by the docker build command to create a container image. Use the ls command to get a directory listing and verify that the file was created. \bin\Release\net6.0\publish\ĭirectory: C:\Users\dapine\App\bin\Release\net6.0\publish Open the Program.cs file in a text editor.įrom the App folder, get a directory listing of the publish folder to verify that the file was created. For this tutorial, you'll use an app that loops indefinitely. The default template creates an app that prints to the terminal and then immediately terminates. The application will run, and print Hello World! below the command: dotnet run Use the dotnet run command to start the app. Change directories and navigate into the App folder, from your terminal session. The dotnet new command creates a new folder named App and generates a "Hello World" console application. Your folder tree will look like the following: 📁 docker-working In the working folder, run the following command to create a new project in a subdirectory named app: dotnet new console -o App -n DotNet.Docker Open your terminal, create a working folder if you haven't already, and enter it. NET app that the Docker container will run. In this tutorial, the name docker-working is used as the working folder.
DOCKSTATION DOCKERFILE HOW TO
If you're using ASP.NET Core, see the Learn how to containerize an ASP.NET Core application tutorial. This tutorial is not for ASP.NET Core apps.
