Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

.NET Cli Tool to package your .NET Core Application into a docker image: 'dotnet dockerize'

License

NotificationsYou must be signed in to change notification settings

brthor/Dockerize.NET

Repository files navigation

Build StatusNuget Version Number

dotnet dockerize -t brthor/serviceWorker:dev

This is a simple dotnet cli tool that enables you to easily package your dotnet app into a docker container. The above invocation creates a docker image with the tagbrthor/serviceWorker:dev which you can thendocker push to your registry ordocker run locally.

The image simply runs thestatic void Main(string[] args) or other entrypoint of your app.

This has many uses:

  • Getting a service image ready for kubernetes environment
  • Testing your application in different OS's available in docker
  • Isolated environments for your app.

Installation

It's easy, add the following to your*.csproj file:

<ItemGroup>  <DotNetCliToolReferenceInclude="Brthor.Dockerize.NET"Version="1.0.0-*" /></ItemGroup>

Thendotnet restore, followed bydotnet dockerize to make your docker image. The default tag is the project name.

Options

Seedotnet dockerize -h for available options.

$ dotnet dockerize -hUsage:  [options]Options:  -t |--tag <tag>      The desired tag name of the created image. Will be directly passed to docker build -t, see docker build --help for more info. Defaults to the project name.  -r |--runtime <RID>  The RID of the specified Base Docker image. Defaults to "linux-x64".  -i |--image <image>  The base docker image used for the generated docker file. If you change this from the default, be sure toupdate BaseRid if appropriate. Defaults to "microsoft/dotnet:2.0-runtime".  -? | -h | --help     Show help information

Example

$ mkdir newApp$cd newApp$ dotnet new consoleThe template"Console Application" was created successfully.... etc output...

At this point you need to editnewApp.csproj and add the tool reference from above, and the whole file will look like:

<ProjectSdk="Microsoft.NET.Sdk">  <PropertyGroup>    <OutputType>Exe</OutputType>    <TargetFramework>netcoreapp2.0</TargetFramework>  </PropertyGroup>  <ItemGroup>    <DotNetCliToolReferenceInclude="Brthor.Dockerize.NET"Version="1.0.0-*" />  </ItemGroup></Project>

Continuing on the command line:

$ dotnet dockerizeDockerize ConfigBase Docker Image: microsoft/dotnet:2.0-runtimeBase Rid of Docker Image: linux-x64Tag: newApp... etc output...$ docker run -it newAppHello World!

Contributing

There's a lot of room for improvement, especially with customization of the underlying dockerfile.Feel free to create pull requests for additional features.

About

.NET Cli Tool to package your .NET Core Application into a docker image: 'dotnet dockerize'

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp