【发布时间】:2020-09-26 23:35:47
【问题描述】:
我正在使用 bitbake 制作嵌入式 linux 映像并在其中复制/运送 asp.net 核心运行时二进制文件。 dotnet --info 命令在容器内工作正常,但它没有执行项目 dll 文件。运行 dotnet NetCore.Docker.dll 时卡住并且没有输出。我尝试了文件、调试和 Console.WriteLine,见下文。
using System;
using System.Threading.Tasks;
using System.IO;
namespace NetCore.Docker
{
class Program
{
static async Task Main(string[] args)
{
var counter = 0;
var max = args.Length != 0 ? Convert.ToInt32(args[0]) : -1;
string[] lines = { "First line", "Second line", "Third line" };
System.IO.File.WriteAllLines(@"file.txt", lines);
while (max == -1 || counter < max)
{
Console.WriteLine($"Counter: {++counter}");
System.Diagnostics.Debug.WriteLine($"Debug Counter: {++counter}");
await Task.Delay(3000);
}
}
}
}
Microsoft 提供了预构建的 docker 映像。 https://docs.microsoft.com/en-us/dotnet/core/docker/build-container?tabs=linux
使用上面的链接,我已经对其进行了测试,并且还在我的嵌入式 linux 容器中复制了相同的环境变量和发布文件夹,但没有任何进展。我需要知道除了 asp.net 核心运行时二进制文件之外,Microsoft docker 容器还有什么。明显的区别是 linux。
微软容器内
$uname -a
Linux 9deb13801df3 4.15.0-118-generic #119~16.04.1-Ubuntu SMP Tue Sep 8 14:54:40 UTC 2020 x86_64 GNU/Linux
在我的嵌入式 linux 容器中
$uname -a
Linux 991873bd82e0 4.14.68-intel-pk-standard #1 SMP PREEMPT Thu Aug 6 19:57:04 PKT 2020 x86_64 x86_64 x86_64 GNU/Linux
我尝试了很多方法,例如在容器 $docker exec -it [container id] /bin/bash 中执行 bash,然后手动运行 $dotnet NetCore.Docker.dll 但没有任何反应。运行 $dotnet --info 会得到正确的结果。
【问题讨论】:
标签: c# .net linux docker containers