在Docker中为自容器.Net Core应用程序指定运行时(Specify runtime for self container .Net Core app in Docker)
我正在开发一个.Net Core应用程序,我的目标是在docker容器中运行。
我的目标是
netcoreapp1.0
框架。 在官方.Net Core SDK映像中构建和运行应用程序时,一切都按预期工作。下一步是拥有一个自包含的应用程序,并使用Microsoft的官方运行时映像,正如他们在此推荐的那样。
我的理解是你必须指定要包含在
project.json
的runtime 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 yourproject.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
最满意答案
当我对你的问题发表评论时,我没有时间详细说明,所以这是一个尝试回答的问题。 代码已经改变了,我不确定我会像现在这样将代码添加到代码中。
然而,使我添加该评论的根本原因仍然存在: 除非您测量并发现相关代码确实对性能产生了显着的负面影响, 否则不要尝试进行优化 。 相反,努力使您的代码尽可能可读 。
我非常怀疑在将数据从磁盘复制到内存后,复制内存中的数据会对性能产生重大影响。 但是,由于您提供的代码无论如何都会对内存中的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 ); 因为如果没有强制转换,您无法将一种类型的指针指定给另一种类型。 这不是(很多) ...
-
Memcpy Char指针(Memcpy Char Pointers)[2023-10-14]
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 ...
-
memcpy在opencl 1.1中(memcpy in opencl 1.1)[2024-04-13]
所以,为此,我在我的设备上定义了一个结构,如下所示: 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 ...
-
交换指针而不是memcpy(Swap pointers instead of memcpy)[2023-07-20]
当我对你的问题发表评论时,我没有时间详细说明,所以这是一个尝试回答的问题。 代码已经改变了,我不确定我会像现在这样将代码添加到代码中。 然而,使我添加该评论的根本原因仍然存在: 除非您测量并发现相关代码确实对性能产生了显着的负面影响, 否则不要尝试进行优化 。 相反,努力使您的代码尽可能可读 。 我非常怀疑在将数据从磁盘复制到内存后,复制内存中的数据会对性能产生重大影响。 但是,由于您提供的代码无论如何都会对内存中的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 ...