consul单机acl docker部署_java


alpine docker


consul单机acl docker部署_python_02


I blogged recently about optimizing .NET and ASP.NET Docker files sizes. .NET Core 2.0 has previously been built on a Debian image but today there is preview image with .NET Core 2.1 nightlies using Alpine. You can read about the announcement here about this new Alpine preview image. There's also a good rollup post on .NET and Docker.

最近写了关于优化.NET和ASP.NET Docker文件大小的博客。 .NET Core 2.0以前是在Debian映像上构建的,但是今天有使用Alpine在.NET Core 2.1夜间发布的预览映像。 您可以在此处阅读有关此新Alpine预览图像的公告在.NET和Docker上也有一篇很好的汇总文章

They have added two new images:

他们添加了两个新图像:

  • 2.1-runtime-alpine
    2.1-runtime-alpine
  • 2.1-runtime-deps-alpine 2.1-runtime-deps-alpine

Alpine support is part of the .NET Core 2.1 release. .NET Core 2.1 images are currently provided at the microsoft/dotnet-nightly repo, including the new Alpine images. .NET Core 2.1 images will be promoted to the microsoft/dotnet repo when released in 2018.

高山支持是.NET Core 2.1版本的一部分。 当前, microsoft / dotnet-nightly库中提供了.NET Core 2.1映像,包括新的Alpine映像。 .NET Core 2.1映像将于2018年发布时将升级为microsoft / dotnet存储库。

NOTE: The -runtime-deps- image contains the dependancies needed for a .NET Core application, but NOT the .NET Core runtime itself. This is the image you'd use if your app was a self-contained application that included a copy of the .NET Core runtime. This is apps published with -r [runtimeid]. Most folks will use the -runtime- image that included the full .NET Core runtime. To be clear:

注意:-runtime-deps-映像包含.NET Core应用程序所需的依赖关系,但不包含.NET Core运行时本身。 如果您的应用程序是包含一个.NET Core运行时副本的自包含应用程序,则使用此图像。 这是使用-r [runtimeid]发布的应用程序。 大多数人将使用-runtime-映像,其中包含完整的.NET Core运行时。 要清楚

- The runtime image contains the .NET Core runtime and is intended to run Framework-Dependent Deployed applications - see sample

- runtime映像包含.NET Core运行时,旨在运行依赖框架的已部署应用程序-请参见示例

- The runtime-deps image contains just the native dependencies needed by .NET Core and is intended to run Self-Contained Deployed applications - see sample

runtime-deps映像仅包含.NET Core所需的本机依赖关系,旨在运行自包含的已部署应用程序-请参见示例

It's best with .NET Core to use multi-stage build files, so you have one container that builds your app and one that contains the results of that build. That way you don't end up shipping an image with a bunch of SDKs and compilers you don't need.

.NET Core最好使用多阶段构建文件,因此,您需要一个容器来构建应用程序,而另一个容器则包含该构建结果。 这样一来,您最终就不会使用大量不需要的SDK和编译器来交付映像。

NOTE: Read this to learn more about image versions in Dockerfiles so you can pick the right tag and digest for your needs. Ideally you'll pick a docker file that rolls forward to include the latest servicing patches.

注意:阅读此内容以了解有关Dockerfiles中映像版本的更多信息,以便您可以选择正确的标记并根据需要进行摘要。 理想情况下,您将选择一个可向前滚动以包含最新服务补丁的docker文件。

Given this docker file, we build with the SDK image, then publish, and the result is about 219megs.

给定此docker文件,我们使用SDK映像进行构建,然后发布,结果约为219megs。

FROM microsoft/dotnet:2.0-sdk as builder  

RUN mkdir -p /root/src/app/dockertest
WORKDIR /root/src/app/dockertest

COPY dockertest.csproj . 
RUN dotnet restore ./dockertest.csproj 

COPY . .
RUN dotnet publish -c release -o published 

FROM microsoft/dotnet:2.0.0-runtime

WORKDIR /root/  
COPY --from=builder /root/src/app/dockertest/published .
ENV ASPNETCORE_URLS=http://+:5000
EXPOSE 5000/tcp
CMD ["dotnet", "./dockertest.dll"]

Then I'll save this as Dockerfile.debian and build like this:

然后,将其另存为Dockerfile.debian并进行如下构建:

> docker build . -t shanselman/dockertestdeb:0.1 -f dockerfile.debian

With a standard ASP.NET app this image ends up being 219 megs.

使用标准的ASP.NET应用程序,此图像最终为219兆。

Now I'll just change one line, and use the 2.1 alpine runtime

现在,我只更改一行,并使用2.1 Alpine运行时

FROM microsoft/dotnet-nightly:2.1-runtime-alpine

And build like this:

并像这样构建:

> docker build . -t shanselman/dockertestalp:0.1 -f dockerfile.alpine

and compare the two:

并比较两个:

> docker images | find /i "dockertest"
shanselman/dockertestalp   0.1  3f2595a6833d   16 minutes ago  82.8MB
shanselman/dockertestdeb   0.1  0d62455c4944   30 minutes ago  219MB

Nice. About 83 megs now rather than 219 megs for a Hello World web app. Now the idea of a microservice is more feasible!

真好现在大约为83兆,而不是Hello World Web应用程序的219兆。 现在,服务的想法更加可行!

Please do head over to the GitHub issue here https:///dotnet/dotnet-docker-nightly/issues/500 and offer your thoughts and results as you test these Alpine images. Also, are you interested in a "-debian-slim?" It would be halfway to Alpine but not as heavy as just -debian.

请访问https:///dotnet/dotnet-docker-nightly/issues/500访问GitHub问题,并在测试这些Alpine图片时提供您的想法和结果。 另外,您对“ -debian-slim”感兴趣吗? 它将到达Alpine的一半,但不如-debian重。

Lots of great stuff happening around .NET and Docker. Be sure to also check out Jeff Fritz's post on creating a minimal ASP.NET Core Windows Container to see how you can squish .(full) Framework applications running on Windows containers as well. For example, the Windows Nano Server images are just 93 megs compressed.

.NET和Docker周围发生了很多很棒的事情。 一定还要查看Jeff Fritz的有关创建最小的ASP.NET Core Windows容器的文章,以了解如何压缩Windows容器上运行的。(full)Framework应用程序。 例如, Windows Nano Server映像仅压缩了93兆

Sponsor: Get the latest JetBrains Rider preview for .NET Core 2.0 support, Value Tracking and Call Tracking, MSTest runner, new code inspections and refactorings, and the Parallel Stacks view in debugger.

赞助商:获取有关.NET Core 2.0支持,值跟踪和呼叫跟踪,MSTest运行器,新代码检查和重构以及调试器中的“并行堆栈”视图的最新JetBrains Rider预览

翻译自: https://www.hanselman.com/blog/trying-out-new-net-core-alpine-docker-images

alpine docker