Docker images for .NET and the .NET Tools.
Перейти к файлу
Michael Simons d599df529d Updated old version #'s in README.md 2015-11-17 16:10:05 -06:00
src/0.0.1.alpha Updated version number to match cli. Also updated onbuild docker file to use executable version of the ENTRYPOINT command. 2015-11-17 16:07:16 -06:00
LICENSE Initial commit 2015-11-16 11:51:06 -08:00
README.md Updated old version #'s in README.md 2015-11-17 16:10:05 -06:00
build.sh Updated version number to match cli. Also updated onbuild docker file to use executable version of the ENTRYPOINT command. 2015-11-17 16:07:16 -06:00
publish.sh Updated version number to match cli. Also updated onbuild docker file to use executable version of the ENTRYPOINT command. 2015-11-17 16:07:16 -06:00

README.md

Supported tags and respective Dockerfile links

What is DotNet?

.NET is a general purpose development platform. It can be used for any kind of app type or workload where general purpose solutions are used. It has several key features that are attractive to many developers, including automatic memory management and modern programming languages, that make it easier to efficiently build high-quality apps. .NET enables a high-level programming environment with many convenience features, while providing low-level access to native memory and APIs.

.NET Core Documentation

How to use this image

Start an instance of your app

The most straightforward way to use this image is to use a DotNet container as both the build and runtime environment. In your Dockerfile, writing something along the lines of the following will compile and run your project:

FROM dotnet:0.0.1.alpha-onbuild

This image includes multiple ONBUILD triggers which should cover most applications. The build will COPY . /dotnetapp and RUN dotnet restore.

This image also includes the ENTRYPOINT dotnet run instruction which will run your application when the Docker image is run.

You can then build and run the Docker image:

$ docker build -t myDotNetApp .
$ docker run -it --rm --name myRunningApp myDotNetApp

Compile your app inside the Docker container

There may be occasions where it is not appropriate to run your app inside a container. To compile, but not run your app inside the Docker instance, you can write something like:

$ docker run --rm -v "$PWD":/myapp -w /myapp dotnet:0.0.1.alpha dotnet compile

This will add your current directory as a volume to the container, set the working directory to the volume, and run the command dotnet compile which will tell dotnet to compile the project in the working directory.

Image Variants

The dotnet images come in many flavors, each designed for a specific use case.

dotnet:<version>

This is the defacto image. If you are unsure about what your needs are, you probably want to use this one. It is designed to be used both as a throw away container (mount your source code and start the container to start your app), as well as the base to build other images off of. This tag is based off of buildpack-deps. buildpack-deps is designed for the average user of docker who has many images on their system. It, by design, has a large number of extremely common Debian packages. This reduces the number of packages that images that derive from it need to install, thus reducing the overall size of all images on your system.

dotnet:<version>-onbuild

This image makes building derivative images easier. For most use cases, creating a Dockerfile in the base of your project directory with the line FROM dotnet:onbuild will be enough to create a stand-alone image for your project.

While the onbuild variant is really useful for "getting off the ground running" (zero to Dockerized in a short period of time), it's not recommended for long-term usage within a project due to the lack of control over when the ONBUILD triggers fire (see also docker/docker#5714, docker/docker#8240, docker/docker#11917).

Once you've got a handle on how your project functions within Docker, you'll probably want to adjust your Dockerfile to inherit from a non-onbuild variant and copy the commands from the onbuild variant Dockerfile (moving the ONBUILD lines to the end and removing the ONBUILD keywords) into your own file so that you have tighter control over them and more transparency for yourself and others looking at your Dockerfile as to what it does. This also makes it easier to add additional requirements as time goes on (such as installing more packages before performing the previously-ONBUILD steps).