Docker: COPY failed: CreateFile, looking for file in strange location?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (1148)

我从我的项目dir运行以下命令:

docker build -t my.solution .
Sending build context to Docker daemon  111.6kB
Step 1/17 : FROM microsoft/aspnetcore:2.0-nanoserver-1709 AS base
 ---> ccfb41c8f5b5
Step 2/17 : WORKDIR /app
 ---> Using cache
 ---> e29a68e16001
Step 3/17 : EXPOSE 80
 ---> Using cache
 ---> 976388139964
Step 4/17 : FROM microsoft/aspnetcore-build:2.0-nanoserver-1709 AS build
 ---> d7ab4e860769
Step 5/17 : WORKDIR /src
 ---> Using cache
 ---> 4ab01220723e
Step 6/17 : COPY my.solution.sln ./
COPY failed: CreateFile \\?\C:\ProgramData\Docker\tmp\docker-builder564035917\my.solution.sln: The system cannot find the file specified.
FROM microsoft/aspnetcore:2.0-nanoserver-1709 AS base
WORKDIR /app
EXPOSE 80

FROM microsoft/aspnetcore-build:2.0-nanoserver-1709 AS build
WORKDIR /src
COPY my.solution.sln ./
COPY my.solution/my.solution.csproj my.solution/
RUN dotnet restore -nowarn:msb3202,nu1503
COPY . .
WORKDIR /src/my.solution
RUN dotnet build -c Release -o /app

FROM build AS publish
RUN dotnet publish -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "my.solution.dll"]
FROM microsoft/aspnetcore:2.0-nanoserver-1709 AS base
WORKDIR /app
EXPOSE 80

FROM microsoft/aspnetcore-build:2.0-nanoserver-1709 AS build
WORKDIR /src
VOLUME C:/tmp
COPY my.solution.sln c:/tmp/
COPY my.solution/my.solution.csproj my.solution/
RUN dotnet restore -nowarn:msb3202,nu1503
COPY . .
WORKDIR /src/my.solution
RUN dotnet build -c Release -o /app

FROM build AS publish
RUN dotnet publish -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "my.solution.dll"]
docker build -t my.solution .
Sending build context to Docker daemon  111.6kB
Step 1/18 : FROM microsoft/aspnetcore:2.0-nanoserver-1709 AS base
 ---> ccfb41c8f5b5
Step 2/18 : WORKDIR /app
 ---> Using cache
 ---> e29a68e16001
Step 3/18 : EXPOSE 80
 ---> Using cache
 ---> 976388139964
Step 4/18 : FROM microsoft/aspnetcore-build:2.0-nanoserver-1709 AS build
 ---> d7ab4e860769
Step 5/18 : WORKDIR /src
Removing intermediate container 31e30e2346aa
 ---> 61c7df20f3c4
Step 6/18 : VOLUME C:/tmp
 ---> Running in fada6c728151
Removing intermediate container fada6c728151
 ---> 7a650440cc1f
Step 7/18 : COPY my.solution.sln c:/tmp/
COPY failed: CreateFile \\?\C:\ProgramData\Docker\tmp\docker-builder832533802\my.solution.sln: The system cannot find the file specified.
提问于
用户回答回答于
VOLUME C:/Users/mysolution
COPY my.solution.sln C:/Users/mysolution
用户回答回答于

我在VS 2017解决方案中发现了同样的情况,其中构建是由dockerComposed启动的,yml文件位于项目上方的一个目录中。

如果想直接用docker文件生成停靠文件,则需要将停靠文件移至上下文的一个级别。

扫码关注云+社区

领取腾讯云代金券