Skip to content

Latest commit

 

History

History
 
 

dotnetapp-dev

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

.NET Core Development Sample

This .NET Core Docker sample demonstrates how to use Docker in your .NET Core development process. The sample works with both Linux and Windows containers.

The sample Dockerfile creates a .NET Core application image based off of the .NET Core SDK Docker base image. It builds and runs the application with the same image, which is a useful strategy for interative development but not optimal for production. Take a look at the .NET Core Production Sample or ASP.NET Core Production Sample for production-oriented samples.

This sample requires Docker 17.06 or later of the Docker client. You need the latest Windows 10 or Windows Server 2016 to use Windows containers. The instructions assume you have the Git client installed.

Getting the sample

The easiest way to get the sample is by cloning the samples repository with git, using the following instructions. You can also just download the repository (it is small) as a zip from the .NET Core Docker samples respository.

git clone https://github.com/dotnet/dotnet-docker-samples/

Build and run the sample with Docker

You can build and run the sample in Docker using the following commands. The instructions assume that you are in the root of the repository.

cd dotnetapp-dev
docker build -t dotnetapp-dev .
docker run --rm dotnetapp-dev Hello .NET Core from Docker

Note: The instructions above work for both Linux and Windows containers. The .NET Core docker images use multi-arch tags, which abstract away different operating system choices for most use-cases.

Build and run the sample locally

You can build and run the sample locally with the .NET Core 2.0 SDK using the following instructions. The instructions assume that you are in the root of the repository.

cd dotnetapp-dev
dotnet run Hello .NET Core

You can produce an application that is ready to deploy to production locally using the following command.

dotnet publish -c release -o published

You can run the application on Windows using the following command.

dotnet published\dotnetapp.dll

You can run the application on Linux or macOS using the following command.

dotnet published/dotnetapp.dll

Note: The -c release argument builds the application in release mode (the default is debug mode). See the dotnet run reference for more information on commandline parameters.

Docker Images used in this sample

The following Docker images are used in this sample

Related Resources