docker - Docker CMD 和 Mount 相互排斥
问题描述
- 用例:我有一个小的dot.net core sdk 3.0 应用程序,它应该在容器内运行。
- 用例:我还将容器文件夹挂载到 Windows 文件系统
图像的 Dockerfile 如下所示:
FROM mcr.microsoft.com/dotnet/core/sdk:3.0
#SET WORKING DIRECTORY
WORKDIR /app
#COPY ALL AND RESTORE
COPY . .
RUN dotnet restore "Modeling\\ModellingMicroServices.sln"
#INSTALL SOFTWARE
SHELL ["cmd", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN Start-Process 'software\\graphviz-2.38.msi' '/qn' -PassThru | Wait-Process;
#CMD SDK3.0
CMD ["Modeling\\MicroServiceModelCompilerCore\\bin\\Debug\\netcoreapp3.0\\MicroServiceModelCompilerCore.exe", "watcher", "Modeling\\MicroServiceModelCompilerCore\\bin\\Debug\\netcoreapp3.0"]
分开的U1和U2工作正常。
U1:
docker build -t mms .
docker run --name mms-c mms
U2:
docker build -t mms .
docker run -d --name mms-c --mount type=bind,source="C:/Users/user/Desktop/ModellingMicroServices/mount",target="C:/app/Modeling/MicroServiceModelCompilerCore/bin/Debug/netcoreapp3.0" mms
问题:
U2仅在我不在CMD
dockerfile 末尾调用命令时才有效。如果我不这样做,则docker run -d --name mms-c --mount
命令返回:
9dd272dec48731982bebffa884a1a6eb81e211763b390eeb18f411781521d5a7
docker: Error response from daemon: container 9dd272dec48731982bebffa884a1a6eb81e211763b390eeb18f411781521d5a7 encountered an error during CreateProcess: failure in a Windows system call: The system can not find the stated file. (0x2)
[Event Detail: Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: onecore\vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(173)\vmcomputeagent.exe!00007FF6157B9D2B: (caller: 00007FF61576E13A) Exception(4) tid(3a0) 80070002 The system cannot find the file specified.
CallContext:[\Bridge_ProcessMessage\VmHostedContainer_ExecuteProcess]
解决方案
您是否尝试添加应用程序的名称?
像这样 :
docker run -d --name mms-c --mount type=bind,source="C:/Users/user/Desktop/ModellingMicroServices/mount/MicroServiceModelCompilerCore.exe",target="C:/app/Modeling/MicroServiceModelCompilerCore/bin/Debug/netcoreapp3.0/MicroServiceModelCompilerCore.exe" mms
推荐阅读
- sql-server - 如何将 nvarchar 值 '********' 转换为数据类型 int
- r - 如何修复“grouped_df_impl(data, unname(vars), drop) 中的错误:列 `...` 未知”。在函数中使用管道、group_by 和汇总
- python - 如何使用 ruamel.yaml 添加评论
- wpf - 在 WPF 的 WrapPanel 中的 LiveCharts 的情况下,它不能垂直滚动,
- amazon-web-services - 使用隧道 EC2 通过 SSH 将 Tableau 最终用户连接到 AWS RDS Aurora
- git - 多个开发人员在一个功能分支上提交
- r - 为什么通过网格搜索调整后随机森林仍然过拟合?
- javascript - 删除 chart.js 条形图中的删除线行为
- c# - 如何将ASCII码发送到串口c#
- chart.js - 我的堆叠条形图中未使用我选择的颜色