.NET Core和Docker以及Microsoft容器注册表入门

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

Simple ASP.NET Core app under Docker

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.

您也可以通过HTTPSDocker上通过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:

新的回购协议如下:

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? 你最近怎么样?

翻译自: https://www.hanselman.com/blog/getting-started-with-net-core-and-docker-and-the-microsoft-container-registry

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值