【问题标题】:Visual Studio's "Docker Debug" fails to install linux package, however release/publish resolves and installs the packageVisual Studio 的“Docker Debug”无法安装 linux 包,但是 release/publish 解决并安装了包
【发布时间】:2021-01-26 00:20:18
【问题描述】:

我正在使用 VS2019,并且在手动创建的 docker 容器中以及通过从 Visual Studio 生成的存根中部署了一个完美运行的服务。 VS 的发布实现没有问题,但是当我从 VS 的调试模式运行容器时,我的服务由于缺少其中一个依赖项而引发异常。

Dockerfile

RUN apt-get update && apt-get install handbrake-cli -y //This is the only line which has been added to the VS2019 dockerfile stub.
ENTRYPOINT ["dotnet", "myapp.dll"]

在调试下观察到的行为,如果我启动 docker exec/CLI

# apt-get install handbrake-cli
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package handbrake-cli
# apt-get update && apt-get install handbrake-cli
...
Reading state information... Done
The following additional packages will be installed:
...
# HandBrakeCLI
[14:11:51] hb_init: starting libhb thread
[14:11:51] thread 7eff9c606700 started ("libhb")
Missing input device. Run HandBrakeCLI --help for syntax.

HandBrake has exited.
#

很明显,在调试模式下,我的 Dockerfile 似乎没有应用更新和安装 handbrake-cli 的行。我曾尝试拆分更新并安装到单独的运行中,但是相同的行为仍然存在。在这一点上,我对自己做错了什么感到有点困惑,因为发布版本不会受到这个问题的影响。

【问题讨论】:

    标签: linux docker .net-core visual-studio-2019 apt


    【解决方案1】:

    C# Discord 中的 Cisien:

    我猜 VS 正在跳过最后阶段并替换它自己来附加调试器

    解决方案是将安装移动到第二行,这样:

    FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim AS base
    RUN apt-get update && apt-get install -y handbrake-cli && apt-get clean
    

    同样建议使用 apt-get clean 来减小图像大小。

    非常感谢 Cisien 及时准确的回复!

    【讨论】:

      猜你喜欢
      • 2017-08-03
      • 1970-01-01
      • 2021-01-07
      • 2019-07-23
      • 2017-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多