Publish your application to a Docker image using the .NET CLI
Setting up your project to use the Docker publisher is very easy. These steps should get you up and running in no time.
The tool will create a Dockerfile
next to your published application and execute docker build
to create an Docker image.
Next, you should change your project.json
file and add the dotnet-publish-docker
package to tools
and add the dotnet publish-docker
to the post-publish script.
"tools": {
"dotnet-publish-docker": "1.0.0-preview1"
},
"scripts": {
"postpublish": "dotnet publish-docker --publish-folder %publish:OutputPath%"
}
It's possible to create your own base Docker image and use this as
--base-image
parameter.
Now you're able to publish your application and you should see it creates a Docker image for your.
dotnet publish
With the Docker CLI you should see your image and will be able to run it.
docker images
docker run --rm <appname>