我是Docker的新手,同时运行Docker文件我的Docker文件
-
FROM microsoft / dotnet:2.2.0-preview1-aspnetcore-runtime AS base
-
WORKDIR / app
-
FROM microsoft / dotnet:2.2.100-preview1-sdk AS build
-
WORKDIR /DineshVisualStudio/Autofac-interceptor/AutofacModule/Autofac.interface.ConcactFactory
-
COPY Autofac.Interface.ConcatFactory.csproj项目/
-
WORKDIR / Autofac-interceptor / project
-
运行网络还原
-
COPY /Autofac.interface.Concactfactory .
-
运行dotnet build -c Release -o / app
-
FROM build AS发布
-
运行dotnet发布-c Release -o / app
-
FROM基地AS决赛
-
WORKDIR / app
-
COPY --from =发布/应用 .
-
ENTRYPOINT ["Autofac.Interface.ConcatFactory.exe"]
运行 build -t myappfactory . 时失败 . 我在COPY命令中为路径尝试了很多组合,但没有运气 .
**我正在使用Visual Studio 2017并且也安装了Docker Tools **这是我的文件夹结构
My folder structure with the code having docker file
docker build -t autofacinterface . . 我每次说创建文件失败都会得到错误 . 系统找不到指定的文件 .
我正在使用Cmd从我当前工作的.csproj文件夹构建docker .
{
D:\DineshVisualStudio\Autofac-
Interceptor\AutofacModule\Autofac.Interface.ConcatFactory>**docker build -t
autofacinterfaceconcatfactory .**
Sending build context to Docker daemon 4.608kB
Step 1/15 : FROM microsoft/dotnet:2.2.0-preview1-aspnetcore-runtime AS base
---> 2df5940c47f7
Step 2/15 : WORKDIR /app
---> Using cache
---> f4d2190d9b44
Step 3/15 : FROM microsoft/dotnet:2.2.100-preview1-sdk AS build
---> af242cb10bf0
Step 4/15 : WORKDIR /DineshVisualStudio/Autofac-
interceptor/AutofacModule/Autofac.interface.ConcactFactory
---> Using cache
---> dbf15787395b
Step 5/15 : COPY /Autofac.Interface.ConcatFactory.csproj project/
COPY failed: CreateFile \\?\C:\ProgramData\Docker\tmp\docker-
builder138146052\COPY: The system cannot find the file specified.
}
**after @Mike suggestion .Now I am getting an issue**
{ D:\DineshVisualStudio\Autofac-
Interceptor\AutofacModule\Autofac.Interface.ConcatFactory>docker build
-t myappfact .
Step 6/15 : WORKDIR /Autofac-interceptor/project
Step 7/15 : RUN dotnet restore
---> Running in 9e91df3e68a3
MSBUILD : error MSB1003: Specify a project or solution file. The current
working directory does not contain a project or solution file.
The command 'cmd /S /C dotnet restore' returned a non-zero code: 1
}
2 回答
我认为你不需要在
COPY /Autofac.Interface.ConcatFactory.csproj
中领先/
. 源文件是相对于当前工作目录的,您之前已经调用了WORKDIR
.https://docs.docker.com/engine/reference/builder/#copy
在Dockerfile中连续两次使用
COPY
这个词吗?