3
votes

I am new to Docker , while running the Docker file ** My Docker file **

  1. FROM microsoft/dotnet:2.2.0-preview1-aspnetcore-runtime AS base
  2. WORKDIR /app
  3. FROM microsoft/dotnet:2.2.100-preview1-sdk AS build
  4. WORKDIR /DineshVisualStudio/Autofac-interceptor/AutofacModule/Autofac.interface.ConcactFactory
  5. COPY Autofac.Interface.ConcatFactory.csproj project/
  6. WORKDIR /Autofac-interceptor/project
  7. RUN dotnet restore
  8. COPY /Autofac.interface.Concactfactory .
  9. RUN dotnet build -c Release -o /app
  10. FROM build AS publish
  11. RUN dotnet publish -c Release -o /app
  12. FROM base AS final
  13. WORKDIR /app
  14. COPY --from=publish /app .
  15. ENTRYPOINT ["Autofac.Interface.ConcatFactory.exe"]

When running the build -t myappfactory . its failing . I tried many combination for the path in COPY command but no luck.

** I am using Visual studio 2017 and had installed Docker Tools too ** This is my folder structure

My folder structure with the code having docker file

docker build -t autofacinterface . . I am getting and Error everytime saying failed to create file . System cannot find the file specified.

I am using Cmd to build the docker from my current working .csproj folder.

{ 
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
}
3
after Mikes suggestion I modified the docker file . 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 }Dinesh Tripathi

3 Answers

3
votes

I don't think you need the leading / in COPY /Autofac.Interface.ConcatFactory.csproj. The source file(s) are relative to current working directory, and you've already called WORKDIR previously.

https://docs.docker.com/engine/reference/builder/#copy

0
votes
Step 5/15 : COPY COPY

Do you have the word COPY twice in a row in your Dockerfile?

0
votes

The command "COPY /Autofac.Interface.ConcatFactory.csproj project/" failed. I recommend you read more about the command COPY here. Use the command "COPY . ." if you run docker build from the folder "D:\DineshVisualStudio\Autofac- Interceptor\AutofacModule\Autofac.Interface.ConcatFactory".