首页新闻找找看学习计划

制作一个镜像文件: docker build -t dockerdemo03 . 问题

0
[待解决问题]

docker build -t dockerdemo03 .
Sending build context to Docker daemon 4.79MB
Step 1/16 : FROM microsoft/dotnet:2.2-aspnetcore-runtime-nanoserver-1803 AS base
---> 5cbb8665953e
Step 2/16 : WORKDIR /app
---> Using cache
---> df6e059247ba
Step 3/16 : EXPOSE 80
---> Using cache
---> 688639444c47
Step 4/16 : FROM microsoft/dotnet:2.2-sdk-nanoserver-1803 AS build
---> 89ff00e52591
Step 5/16 : WORKDIR /src
---> Using cache
---> 36386d24af66
Step 6/16 : COPY ["WebApplication14/WebApplication14.csproj", "WebApplication14/"]
COPY failed: CreateFile \?\C:\ProgramData\Docker\tmp\docker-builder390208715\WebApplication14\WebApplication14.csproj: The system cannot find the path specified.

问题补充:

Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed.

For more information, please see https://aka.ms/containercompat

FROM microsoft/dotnet:2.2-aspnetcore-runtime-nanoserver-1803 AS base
WORKDIR /app
EXPOSE 80

FROM microsoft/dotnet:2.2-sdk-nanoserver-1803 AS build
WORKDIR /src
COPY ["WebApplication14/WebApplication14.csproj", "WebApplication14/"]
RUN dotnet restore "WebApplication14/WebApplication14.csproj"
COPY . .
WORKDIR "/src/WebApplication14"
RUN dotnet build "WebApplication14.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "WebApplication14.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "WebApplication14.dll"]

conan_lin的主页 conan_lin | 初学一级 | 园豆:5
提问于:2019-08-26 16:42

系统找不到指定的路径。
dockerfile贴出来看一下

默卿 1个月前

@默卿: 贴了

conan_lin 1个月前
< >
分享
所有回答(1)
0

http://www.likecs.com/show-57645.html 你看下这个帖子里面这段描述,然后检查下dockerfile文件的位置对不对:
“添加docker支持后会自动生成dockerfile文件,这里有一个坑,在COPY ["myWebApp/myWebApp.csproj", "myWebApp/"]行中需要注意是myWebApp/myWebApp.csproj,是myWebApp目录下的myWebApp.csproj工程文件,所以需要把创建好的dockerfile拷贝到工程文件目录下。”

默卿 | 园豆:3869 (老鸟四级) | 2019-08-26 17:05

默认生成文件是在 E:\myWebApp\myWebApp 目录
吧文件拷贝到 E:\myWebApp 目录即可

PS E:\myWebApp> docker build -t aspnetdemo .
Sending build context to Docker daemon 18.94kB
Step 1/17 : FROM microsoft/dotnet:2.2-aspnetcore-runtime-nanoserver-1803 AS base
---> 5cbb8665953e
Step 2/17 : WORKDIR /app
---> Using cache
---> df6e059247ba
Step 3/17 : EXPOSE 80
---> Using cache
---> 688639444c47
Step 4/17 : EXPOSE 443
---> Using cache
---> 25252aa83f01
Step 5/17 : FROM microsoft/dotnet:2.2-sdk-nanoserver-1803 AS build
---> 89ff00e52591
Step 6/17 : WORKDIR /src
---> Using cache
---> 36386d24af66
Step 7/17 : COPY ["myWebApp/myWebApp.csproj", "myWebApp/"]
---> 759a145918db
Step 8/17 : RUN dotnet restore "myWebApp/myWebApp.csproj"
---> Running in 465b262be070
Restore completed in 12.44 sec for C:\src\myWebApp\myWebApp.csproj.
Removing intermediate container 465b262be070
---> 9d53c864a5be
Step 9/17 : COPY . .
---> 09834f5154be
Step 10/17 : WORKDIR "/src/myWebApp"
---> Running in 04ec991761af
Removing intermediate container 04ec991761af
---> 43b4ce2108ad
Step 11/17 : RUN dotnet build "myWebApp.csproj" -c Release -o /app
---> Running in e2461cf7d025
Microsoft (R) Build Engine version 16.2.32702+c4012a063 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

Restore completed in 1.54 sec for C:\src\myWebApp\myWebApp.csproj.
myWebApp -> C:\app\myWebApp.dll

Build succeeded.
0 Warning(s)
0 Error(s)

Time Elapsed 00:00:08.65
Removing intermediate container e2461cf7d025
---> 7067fe091ef5
Step 12/17 : FROM build AS publish
---> 7067fe091ef5
Step 13/17 : RUN dotnet publish "myWebApp.csproj" -c Release -o /app
---> Running in 7a9504d70ebb
Microsoft (R) Build Engine version 16.2.32702+c4012a063 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

Restore completed in 1.37 sec for C:\src\myWebApp\myWebApp.csproj.
myWebApp -> C:\src\myWebApp\bin\Release\netcoreapp2.2\myWebApp.dll
myWebApp -> C:\app Removing intermediate container 7a9504d70ebb
---> d71b62eba76c
Step 14/17 : FROM base AS final
---> 25252aa83f01
Step 15/17 : WORKDIR /app
---> Running in ace56ce26583
Removing intermediate container ace56ce26583
---> bee380f7ea7b
Step 16/17 : COPY --from=publish /app .
---> 9e2856414a5a
Step 17/17 : ENTRYPOINT ["dotnet", "myWebApp.dll"]
---> Running in f4aa0bbe25fa
Removing intermediate container f4aa0bbe25fa
---> c8e18fad8b33
Successfully built c8e18fad8b33
Successfully tagged aspnetdemo:latest
PS E:\myWebApp> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
aspnetdemo latest c8e18fad8b33 2 minutes ago 524MB
<none> <none> d71b62eba76c 3 minutes ago 1.8GB
microsoft/dotnet 2.2-sdk-nanoserver-1803 89ff00e52591 11 days ago 1.79GB
microsoft/dotnet 2.2-aspnetcore-runtime-nanoserver-1803 5cbb8665953e 11 days ago 523MB
PS E:\myWebApp> docker run -d -p 8010:80 aspnetdemo
566e3b0437c8cff78e2c53672ea11b19de47d95040ddc246d5e377f2d1a6ca61
PS E:\myWebApp>

支持(0) 反对(0) conan_lin | 园豆:5 (初学一级) | 2019-08-26 17:41

项目如果打了txt文件日志 在哪里可以看到对应的文件呢

支持(0) 反对(0) conan_lin | 园豆:5 (初学一级) | 2019-08-26 17:48

@conan_lin: 容器是个隔离的环境,内部也有一套文件路径,先找到运行项目的容器,进入容器之后,去找txt文件的位置,比如项目里存的日志路径是/home/log,那进入容器以后,就在这个文件夹下面找日志。一般运行容器的时候做一下持久化比较好,通过-v命令把容器的日志目录挂载到宿主机的某个文件夹上,这样找日志的时候就不需要进入容器内部,而是直接在宿主机的文件夹里看。

支持(0) 反对(0) 默卿 | 园豆:3869 (老鸟四级) | 2019-08-26 18:01

@默卿: 感谢

支持(0) 反对(0) conan_lin | 园豆:5 (初学一级) | 2019-08-27 08:56
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册