Skip to content

Commit 4ef71df

Browse files
committed
Add .NET Core Docker samples
0 parents  commit 4ef71df

27 files changed

+829
-0
lines changed

.gitignore

+271
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
1+
## Ignore Visual Studio temporary files, build results, and
2+
## files generated by popular Visual Studio add-ons.
3+
4+
# User-specific files
5+
*.suo
6+
*.user
7+
*.userosscache
8+
*.sln.docstates
9+
10+
# User-specific files (MonoDevelop/Xamarin Studio)
11+
*.userprefs
12+
13+
# Build results
14+
[Dd]ebug/
15+
[Dd]ebugPublic/
16+
[Rr]elease/
17+
[Rr]eleases/
18+
x64/
19+
x86/
20+
bld/
21+
[Bb]in/
22+
[Oo]bj/
23+
[Ll]og/
24+
25+
# Visual Studio 2015 cache/options directory
26+
.vs/
27+
# Uncomment if you have tasks that create the project's static files in wwwroot
28+
#wwwroot/
29+
30+
# MSTest test Results
31+
[Tt]est[Rr]esult*/
32+
[Bb]uild[Ll]og.*
33+
34+
# NUNIT
35+
*.VisualState.xml
36+
TestResult.xml
37+
38+
# Build Results of an ATL Project
39+
[Dd]ebugPS/
40+
[Rr]eleasePS/
41+
dlldata.c
42+
43+
# DNX
44+
project.lock.json
45+
project.fragment.lock.json
46+
artifacts/
47+
48+
*_i.c
49+
*_p.c
50+
*_i.h
51+
*.ilk
52+
*.meta
53+
*.obj
54+
*.pch
55+
*.pdb
56+
*.pgc
57+
*.pgd
58+
*.rsp
59+
*.sbr
60+
*.tlb
61+
*.tli
62+
*.tlh
63+
*.tmp
64+
*.tmp_proj
65+
*.log
66+
*.vspscc
67+
*.vssscc
68+
.builds
69+
*.pidb
70+
*.svclog
71+
*.scc
72+
73+
# Chutzpah Test files
74+
_Chutzpah*
75+
76+
# Visual C++ cache files
77+
ipch/
78+
*.aps
79+
*.ncb
80+
*.opendb
81+
*.opensdf
82+
*.sdf
83+
*.cachefile
84+
*.VC.db
85+
*.VC.VC.opendb
86+
87+
# Visual Studio profiler
88+
*.psess
89+
*.vsp
90+
*.vspx
91+
*.sap
92+
93+
# TFS 2012 Local Workspace
94+
$tf/
95+
96+
# Guidance Automation Toolkit
97+
*.gpState
98+
99+
# ReSharper is a .NET coding add-in
100+
_ReSharper*/
101+
*.[Rr]e[Ss]harper
102+
*.DotSettings.user
103+
104+
# JustCode is a .NET coding add-in
105+
.JustCode
106+
107+
# TeamCity is a build add-in
108+
_TeamCity*
109+
110+
# DotCover is a Code Coverage Tool
111+
*.dotCover
112+
113+
# Visual Studio code coverage results
114+
*.coverage
115+
*.coveragexml
116+
117+
# NCrunch
118+
_NCrunch_*
119+
.*crunch*.local.xml
120+
nCrunchTemp_*
121+
122+
# MightyMoose
123+
*.mm.*
124+
AutoTest.Net/
125+
126+
# Web workbench (sass)
127+
.sass-cache/
128+
129+
# Installshield output folder
130+
[Ee]xpress/
131+
132+
# DocProject is a documentation generator add-in
133+
DocProject/buildhelp/
134+
DocProject/Help/*.HxT
135+
DocProject/Help/*.HxC
136+
DocProject/Help/*.hhc
137+
DocProject/Help/*.hhk
138+
DocProject/Help/*.hhp
139+
DocProject/Help/Html2
140+
DocProject/Help/html
141+
142+
# Click-Once directory
143+
publish/
144+
145+
# Publish Web Output
146+
*.[Pp]ublish.xml
147+
*.azurePubxml
148+
# TODO: Comment the next line if you want to checkin your web deploy settings
149+
# but database connection strings (with potential passwords) will be unencrypted
150+
*.pubxml
151+
*.publishproj
152+
153+
# Microsoft Azure Web App publish settings. Comment the next line if you want to
154+
# checkin your Azure Web App publish settings, but sensitive information contained
155+
# in these scripts will be unencrypted
156+
PublishScripts/
157+
158+
# NuGet Packages
159+
*.nupkg
160+
# The packages folder can be ignored because of Package Restore
161+
**/packages/*
162+
# except build/, which is used as an MSBuild target.
163+
!**/packages/build/
164+
# Uncomment if necessary however generally it will be regenerated when needed
165+
#!**/packages/repositories.config
166+
# NuGet v3's project.json files produces more ignoreable files
167+
*.nuget.props
168+
*.nuget.targets
169+
170+
# Microsoft Azure Build Output
171+
csx/
172+
*.build.csdef
173+
174+
# Microsoft Azure Emulator
175+
ecf/
176+
rcf/
177+
178+
# Windows Store app package directories and files
179+
AppPackages/
180+
BundleArtifacts/
181+
Package.StoreAssociation.xml
182+
_pkginfo.txt
183+
184+
# Visual Studio cache files
185+
# files ending in .cache can be ignored
186+
*.[Cc]ache
187+
# but keep track of directories ending in .cache
188+
!*.[Cc]ache/
189+
190+
# Others
191+
ClientBin/
192+
~$*
193+
*~
194+
*.dbmdl
195+
*.dbproj.schemaview
196+
*.jfm
197+
*.pfx
198+
*.publishsettings
199+
node_modules/
200+
orleans.codegen.cs
201+
202+
# Since there are multiple workflows, uncomment next line to ignore bower_components
203+
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
204+
#bower_components/
205+
206+
# RIA/Silverlight projects
207+
Generated_Code/
208+
209+
# Backup & report files from converting an old project file
210+
# to a newer Visual Studio version. Backup files are not needed,
211+
# because we have git ;-)
212+
_UpgradeReport_Files/
213+
Backup*/
214+
UpgradeLog*.XML
215+
UpgradeLog*.htm
216+
217+
# SQL Server files
218+
*.mdf
219+
*.ldf
220+
221+
# Business Intelligence projects
222+
*.rdl.data
223+
*.bim.layout
224+
*.bim_*.settings
225+
226+
# Microsoft Fakes
227+
FakesAssemblies/
228+
229+
# GhostDoc plugin setting file
230+
*.GhostDoc.xml
231+
232+
# Node.js Tools for Visual Studio
233+
.ntvs_analysis.dat
234+
235+
# Visual Studio 6 build log
236+
*.plg
237+
238+
# Visual Studio 6 workspace options file
239+
*.opt
240+
241+
# Visual Studio LightSwitch build output
242+
**/*.HTMLClient/GeneratedArtifacts
243+
**/*.DesktopClient/GeneratedArtifacts
244+
**/*.DesktopClient/ModelManifest.xml
245+
**/*.Server/GeneratedArtifacts
246+
**/*.Server/ModelManifest.xml
247+
_Pvt_Extensions
248+
249+
# Paket dependency manager
250+
.paket/paket.exe
251+
paket-files/
252+
253+
# FAKE - F# Make
254+
.fake/
255+
256+
# JetBrains Rider
257+
.idea/
258+
*.sln.iml
259+
260+
# CodeRush
261+
.cr/
262+
263+
# Python Tools for Visual Studio (PTVS)
264+
__pycache__/
265+
*.pyc
266+
267+
# Cake - Uncomment if you are using it
268+
# tools/
269+
270+
# VS Code
271+
.vscode/

LICENSE.TXT

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) .NET Foundation and Contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.NET Core Docker Samples
2+
========================
3+
4+
This repo contains samples that demonstrate various .NET Core docker configurations. You can use these samples as a basis for creating docker images for your .NET Core apps. It is also the source for the Docker Hub [microsoft/dotnet-core-samples] repo.
5+
6+
You need to have the [.NET Core SDK](https://dot.net/core) and [Docker client](https://www.docker.com/products/docker) installed to use these samples.
7+
8+
These samples rely on (AKA 'FROM') the [.NET Core Docker images](https://hub.docker.com/r/microsoft/dotnet/) on Dockerhub, provided by the .NET Team at Microsoft. There are multiple images to choose from. They differ on a few different axes that are important to understand. The samples, in large part, exercise these different axes:
9+
10+
- .NET Core distribution - .NET Core SDK, .NET Core Runtime, .NET Core dependencies only
11+
- Operating System - Windows and Linux
12+
- Docker pattern - Regular vs. [ONBUILD](https://docs.docker.com/engine/reference/builder/#onbuild)
13+
14+
Docker uses [docker/whalesay](https://hub.docker.com/r/docker/whalesay/) for its samples. The .NET Core Team at Microsoft uses [dotnetbot](https://github.com/dotnet-bot). dotnetbot is the mascot for .NET open source projects. Got something to say? Both whalesay and dotnetbot are great listeners.
15+
16+
.NET Core Samples
17+
-----------------
18+
19+
You can pick the sample that best fits the scenario you are interested in. You will notice that each sample supports multiple operating systems via multiple Dockerfiles. The instructions for each sample describe how to target Windows or Linux.
20+
21+
**Getting Started**
22+
23+
- [dotnetapp](dotnetapp) - This sample is the best one to start with. You don't need much knowledge of .NET Core or Docker.
24+
25+
Note: The dotnetapp sample uses the Docker [ONBUILD](https://docs.docker.com/engine/reference/builder/#onbuild) pattern, which makes it easy to create a Docker image by prescribing file names and locations. You are not encouraged to use this example for more than developing familiarity with Docker and .NET Core, not for development or production.
26+
27+
**Development**
28+
29+
- [dotnetbot] - This sample is good for development since it performs `dotnet` commands on your behalf, reducing the time it takes to create Docker images (assuming you make changes and then test them in a container, iteratively). It is very similar to the dotnetapp sample above, but doesn't prescribe filesname (you can change them for your app).
30+
31+
**Production**
32+
33+
- [dotnetbot-prod](dotnetbot-prod)(dotnetbot-prod) - This sample is good for production since it does not include the .NET CLI tools but only the .NET Core Runtime. Most apps only need the runtime, reducing the size of your .NET Core base image.
34+
- [dotnetbot-selfcontained](dotnetbot-selfcontained)- This sample is also good for production scenarios. It's for deploying [self-contained .NET Core apps](https://docs.microsoft.com/dotnet/articles/core/deploying/), which include .NET Core as part of the app and not as a centrally installed component in a base image.
35+
36+
Note: The dotnetbot-prod sample is best for scenarios where there are multiple .NET Core containers being hosted in an environment, to enable sharing of base images, including the .NET Core Runtime. If there is just one or a few .NET Core containers, then the dotnetbot-selfcontained sample could be a better choice.
37+
38+
Note: The current tools for creasing [self-contained .NET Core apps](https://docs.microsoft.com/dotnet/articles/core/deploying/) is not yet optimal. These tools will be improved so that self-contained apps are much smaller.

dotnetapp/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM microsoft/dotnet:onbuild

dotnetapp/Dockerfile.nano

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM microsoft/dotnet:nanoserver-onbuild

dotnetapp/Dockerfile.servercore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM microsoft/dotnet:windowsservercore-onbuild

0 commit comments

Comments
 (0)