It's super easy to get started with .NET Core and/or ASP.NET Core with Docker. If you have Docker installed you don't need to install anything to try out .NET Core, of course.
开始使用Docker的.NET Core和/或ASP.NET Core超级容易。 当然,如果您安装了Docker,则无需安装任何程序即可试用.NET Core。
To run a little .NET Core console app:
要运行一个.NET Core控制台应用程序:
docker run --rm mcr.microsoft.com/dotnet/core/samples:dotnetapp
And the result:
结果:
latest: Pulling from dotnet/core/samples
Hello from .NET Core!
...SNIP...
**Environment**
Platform: .NET Core
OS: Linux 4.9.125-linuxkit #1 SMP Fri Sep 7 08:20:28 UTC 2018
To run a quick little ASP.NET Core website just:
要运行一个快速的ASP.NET Core小网站,只需:
docker run -it --rm -p 8000:80 --name aspnetcore_sample mcr.microsoft.com/dotnet/core/samples:aspnetapp
And here it is running on localhost:8000
它在本地主机上运行:8000
You can also host ASP.NET Core Images with Docker over HTTPS to with this image, or run ASP.NET Core apps in Windows Containers.
您也可以通过HTTPS在Docker上通过Docker托管ASP.NET Core映像,或在该映像中运行ASP.NET Core应用。
Note that Microsoft teams are now publishing container images to the MCR (Microsoft Container Registry) so they can use the Azure CDN and pull faster when they are closer to you globally. The images start at MCR and then can be syndicated to other container registries.
请注意,Microsoft团队现在正在将容器映像发布到MCR (Microsoft容器注册表),以便他们可以使用Azure CDN并在全球范围内离您最近的情况下更快地进行拉取。 图像从MCR开始,然后可以联合到其他容器注册表。
The new repos follow:
新的回购协议如下:
.NET Core Runtime dependencies (just the stuff .NET Core needs, but not .NET Core itself - useful if you want to distribute your own copy and still want a small container image size)
.NET Core运行时依赖项(仅.NET Core所需的东西,而.NET Core本身则不需要-如果您希望分发自己的副本并且仍然希望容器图像尺寸较小,则很有用)
.NET Core Runtime (Just what's needed to run a .NET Core app)
.NET Core运行时(仅需要运行.NET Core应用程序)
.NET Core SDK (includes the compilers, everything)
.NET Core SDK (包括编译器,应有尽有)
ASP.NET Core runtime (everything you need to RUN your ASP.NET Core web app)
ASP.NET Core运行时(运行ASP.NET Core Web应用程序所需的一切)
When you "docker pull" you can use tag strings for .NET Core and it works across any supported .NET Core version
当您“ docker pull”时,您可以为.NET Core使用标签字符串,并且它可以在任何受支持的.NET Core版本中使用
SDK:
docker pull mcr.microsoft.com/dotnet/core/sdk:2.1
SDK:
docker pull mcr.microsoft.com/dotnet/core/sdk:2.1
ASP.NET Core Runtime:
docker pull mcr.microsoft.com/dotnet/core/aspnet:2.1
ASP.NET Core运行时:
docker pull mcr.microsoft.com/dotnet/core/aspnet:2.1
.NET Core Runtime:
docker pull mcr.microsoft.com/dotnet/core/runtime:2.1
.NET Core运行时:
docker pull mcr.microsoft.com/dotnet/core/runtime:2.1
.NET Core Runtime Dependencies:
docker pull mcr.microsoft.com/dotnet/core/runtime-deps:2.1
.NET Core运行时依赖项:
docker pull mcr.microsoft.com/dotnet/core/runtime-deps:2.1
For example, I can run the .NET Core 3.0 SDK and mess around with it like this:
例如,我可以运行.NET Core 3.0 SDK并像这样弄乱它:
docker run -it mcr.microsoft.com/dotnet/core/sdk:3.0
I've been using Docker to run my unit tests on my podcast site within a container locally. Then I volume mount and dump the test results out in a local folder and inspect them with Visual Studio
我一直在使用Docker在本地容器中的播客站点上运行单元测试。 然后,我将测试结果卷装入并转储到本地文件夹中,并使用Visual Studio检查它们
docker build --pull --target testrunner -t podcast:test .
docker run --rm -v c:\github\hanselminutes-core\TestResults:/app/hanselminutes.core.tests/TestResults podcast:test
I can then either host the Docker container in Azure App Service for Containers, or as little one-off per-second billed instances with Azure Container Instances (ACI).
然后,我可以在容器的Azure应用服务中托管Docker容器,或者使用Azure容器实例(ACI)托管每秒少一次的计费实例。
Have you been using .NET Core in Docker? How has it been going for you?
您是否一直在Docker中使用.NET Core? 你最近怎么样?