首页 \ 问答 \ 在Docker中为自容器.Net Core应用程序指定运行时(Specify runtime for self container .Net Core app in Docker)

在Docker中为自容器.Net Core应用程序指定运行时(Specify runtime for self container .Net Core app in Docker)

我正在开发一个.Net Core应用程序,我的目标是在docker容器中运行。

我的目标是netcoreapp1.0框架。 在官方.Net Core SDK映像中构建和运行应用程序时,一切都按预期工作。

下一步是拥有一个自包含的应用程序,并使用Microsoft的官方运行时映像,正如他们在此推荐的那样。

我的理解是你必须指定要包含在project.jsonruntime section中的runtime section

我的问题是: microsoft/dotnet:runtime在哪个运行microsoft/dotnet:runtime使用它们的最新映像版本?

Microsoft Docs网站上有很多不同的Ubuntu运行时可供选择:

  • ubuntu.14.04-64
  • ubuntu.14.10-64
  • ubuntu.15.04-64
  • ubuntu.15.10-64
  • ubuntu.16.04-64
  • ubuntu.16.10-64

该应用程序将作为Linux容器运行,而不是Windows容器。


I'm working on a .Net Core app, which I aim to run in production in a docker container.

I'm targeting the netcoreapp1.0 framework. When building and running the application in the official .Net Core SDK image, everything works as expected.

The next step is to have a self contained app and use the official runtime image from Microsoft instead, as they recommend here.

What I understand is you have to specify which runtimes you want to include in the runtime section in your project.json.

My question is: Which runtime do microsoft/dotnet:runtime use under the hood for their latest image version?

There are a lot of different i.e Ubuntu runtimes to targets to choose from on Microsoft Docs Website:

  • ubuntu.14.04-x64
  • ubuntu.14.10-x64
  • ubuntu.15.04-x64
  • ubuntu.15.10-x64
  • ubuntu.16.04-x64
  • ubuntu.16.10-x64

The application will run as a Linux Container, NOT a Windows Container.


原文:https://stackoverflow.com/questions/41482203
更新时间:2024-01-06 13:01

最满意答案

当我对你的问题发表评论时,我没有时间详细说明,所以这是一个尝试回答的问题。 代码已经改变了,我不确定我会像现在这样将代码添加到代码中。

然而,使我添加该评论的根本原因仍然存在: 除非您测量并发现相关代码确实对性能产生了显着的负面影响, 否则不要尝试进行优化 。 相反,努力使您的代码尽可能可读

我非常怀疑在将数据从磁盘复制到内存后,复制内存中的数据会对性能产生重大影响。 但是,由于您提供的代码无论如何都会对内存中的struct布局做出假设,因此直接读入struct不会真正降低代码的可读性(或者更不容易对该布局进行更改):

COUPLE titanic;
FILE *f = fopen("myfile", "rb");
fread(&titanic, sizeof(titanic), 1, f);

或者,如果您确实有一个数组,请直接读入数组:

COUPLE titanic[SIZE];
FILE *f = fopen("myfile", "rb");
fread(&titanic, sizeof(titanic), SIZE, f);

取决于SIZE ,后者确实可以在性能上产生潜在的巨大差异。 对于较大的块,访问磁盘以获得更大的块通常更快。 (尽管磁盘缓存可能会减轻这种情况。)


When made my comment to your question, I didn't have the time to elaborate, so here's an attempt to answer. The code has changed since, and I'm not sure I would add that comment to the code as it is now.

Nevertheless, the underlying reason that made me add that comment still stands: Unless you measured and found that the code in question does indeed have a significant negative impact on performance, don't attempt to optimize. Instead, strive to make your code as readable as possible.

I seriously doubt that copying the data in memory will have a significant performance impact after copying them from the disk into memory. However, since your code as provided makes assumptions about the struct's layout in memory anyway, directly reading into the struct wouldn't really make the code less readable (or less vulnerable to changes to that layout):

COUPLE titanic;
FILE *f = fopen("myfile", "rb");
fread(&titanic, sizeof(titanic), 1, f);

Or, if you indeed have an array, read into the array directly:

COUPLE titanic[SIZE];
FILE *f = fopen("myfile", "rb");
fread(&titanic, sizeof(titanic), SIZE, f);

Depending on SIZE, the latter could indeed make a potentially huge difference in performance. Accessing the disk for bigger chunks is, in general, faster that doing it for smaller chunks. (Although disk caching might alleviate that.)

相关问答

更多
  • 在1989年标准中添加void数据类型之前,就像memcpy这样的函数被设计了。 char *是当时最接近“通用”指针的东西。 问题是如果memcpy仍然使用char *参数并且你想在不是char数组的目标上调用memcpy ,则必须显式地转换指针值: int foo[N]; int bar[N]; ... memcpy( (char *) foo, (const char *) bar, N * sizeof *foo ); 因为如果没有强制转换,您无法将一种类型的指针指定给另一种类型。 这不是(很多) ...
  • char * concat(const char * first, const char * second) { int lf = strlen(first); int ls = strlen(second); int len = lf + ls; char * rb = new char[len+1];//You need this +1 here memcpy(rb, first, lf); memcpy(rb+lf, second, ls); r ...
  • 首先是一个大警告: “不安全必须死” http://blog.takipi.com/still-unsafe-the-major-bug-in-java-6-that-turned-into-a-java-9-feature/ 一些先决条件 static class DataHolder { int i1; int i2; int i3; DataHolder d1; DataHolder d2; public DataHolder(int i1, int i ...
  • 所以,为此,我在我的设备上定义了一个结构,如下所示: typedef struct { uint3 dims; __global uint* element_begIndices; __global uint n_element_cells; __global uint* element_cells; } Grid; 然后我只使用以下内核来填充Grid类型的内存: // a kernel to fill a grid acceleration structure. __ke ...
  • 因为*(void **)dest = *(void **)src; != memmove(dest, src, elementSize); 首先是分配操作,其中memmove()将内存从src复制到dest (深度复制) 编辑 假设你的dest和src是这样的? src 5 6 7 8 +-----+ +--+--+--+---+ | 5 +----->| A|B |C | D | +-----+ +--+--+--+---+ ...
  • 这个怎么样: vec3* client::pos() { return (vec3*)(state() + 0x1C); } 这样,pos()应返回指向内部存储数据的vec3指针。 然后pos()的调用者可以直接修改该数据(如果这真的是你想要的)。 请注意,你给出了内部存储器的指针,你必须以某种方式处理内存生存期问题(例如,如果state()稍后指向不同的内存而某人仍然使用pos()的返回值会发生什么?)。 How about this: vec3* client::pos() { ret ...
  • 它的段错误是4000,但它不是memcpy()的错。 这是因为大小超出了程序的堆栈大小。 尝试动态分配数组,它应该很好,像这样 float *temp; temp = malloc(sizeof(float) * n * n); if (temp != NULL) { /* memcpys here */ } 请注意,与数组不同,这不能用两个索引符号访问,以达到您需要的类似效果 float **temp; temp = malloc(sizeof(float *) * n); for (size_ ...
  • 这会更改指针ptr指向的地址 : ptr = &value; 这会更改指针ptr指向的地址处的数据 : memcpy(ptr, &value, sizeof(char*)); 在第二种情况下, ptr仍然指向与调用之前相同的地址。 所以它们绝不是一样的。 This changes the address that the pointer ptr points to: ptr = &value; This changes the data at the address that the pointer ...
  • 当我对你的问题发表评论时,我没有时间详细说明,所以这是一个尝试回答的问题。 代码已经改变了,我不确定我会像现在这样将代码添加到代码中。 然而,使我添加该评论的根本原因仍然存在: 除非您测量并发现相关代码确实对性能产生了显着的负面影响, 否则不要尝试进行优化 。 相反,努力使您的代码尽可能可读 。 我非常怀疑在将数据从磁盘复制到内存后,复制内存中的数据会对性能产生重大影响。 但是,由于您提供的代码无论如何都会对内存中的struct布局做出假设,因此直接读入struct不会真正降低代码的可读性(或者更不容易对该 ...
  • 不, memcpy不做任何关于对齐的假设。 它在功能上等同于逐字节复制。 顺便说一句,通过不是字符类型的不同类型的左值访问auto对象会导致未定义的行为,无论是否对齐。 这违反了有效类型规则 C11 6.5 p6和p7。 No, memcpy doesn't make any assumptions about alignement. It is functionally equivalent to copying byte by byte. BTW, accessing an auto object th ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)