Docker CMD和Mount相互排除 用例:我有一个小型的dot.net核心sdk 3.0应用程序,应该在容器中运行 用例:我还将把容器文件夹装载到windows文件系统

Docker CMD和Mount相互排除 用例:我有一个小型的dot.net核心sdk 3.0应用程序,应该在容器中运行 用例:我还将把容器文件夹装载到windows文件系统,docker,Docker,图像的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", "$ErrorActionPre

图像的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"]
分开的U1U2效果很好

U1: U2:
问题: U2仅在我不调用dockerfile末尾的
CMD
命令时有效。如果I不这样做,则
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

谢谢你的回复。我只需要挂载应用程序的目录。不是应用程序本身。我在一个超级简单的命令行应用程序中重现了这个用例,它的工作方式非常好。从容器创建的文件将被交换到文件系统。在本例中,应交换在
C:/app/Modeling/MicroServiceModelCompilerCore/bin/Debug/netcoreapp3.0
中创建的文件;这将隐藏图像中的所有内容。挂载文件夹中实际有什么?你能在容器中选择一个不同的目录来保存它吗?这是正确的,而且完全有意义,我将更改容器目标目录。谢谢你的回答!
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