Reputation: 461
I created a simple aspnet core app to play with docker. Placed Dockerfile and dockerignore inside the solution folder.
Dockerfile:
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build
LABEL maintainer [email protected]
WORKDIR /home/dejant/desktop/app
COPY . .
RUN dotnet restore
RUN dotnet publish ./ParallelDemo/ParallelDemo.csproj -o /publish/
WORKDIR /publishdocker
ENTRYPOINT ["dotnet", "/bin/ParallelDemo.dll"]
Steps leading to the failed container run can be seen here:
Upvotes: 0
Views: 1220
Reputation: 1021
In Dockerfile the Entrypoint should simply define the executable to be used (a single file/command, not the full command). In your case you should change it to ENTRYPOINT ["dotnet"]
and add a CMD definition at the end of the file CMD ["/bin/ParallelDemo.dll"]
. In essence what docker will do is actually execute dotnet /bin/ParallelDemo.dll
Also I noticed that you are changing WORKDIR to what appears to be a folder on your host machine. The WORKDIR in essence is like running cd /path/to/driectory inside the container filesystem. So you should just use the COPY to add the app folder to the image like so COPY /home/dejant/desktop/app app
I also don't know what the publish command really does, but I see that you also change the WORKDIR to /publishdocker and then in the ENTRYPOINT run a .dll thats in /bin/ folder, which in essence means that the last WORKDIR is unnecessary.
And I'm not a .NET developer, but I am assumint that the -o flag defines where you want your project to be published? So probably the .dll file is also located somewhere in that directory
So your Dockerfile becomes something like:
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build
LABEL maintainer [email protected]
COPY /home/dejant/desktop/app /app
WORKDIR /app
RUN dotnet restore
RUN dotnet publish ./ParallelDemo/ParallelDemo.csproj -o /publish/
ENTRYPOINT ["dotnet"]
CMD ["/THE/CORRECT/PATH/TO/YOUR/.DLL/LOCATION"] ## Replace with the proper value
UPDATE
And actually since you seem to intend to use this as part of a multi-stage build, then you probably would just want to build the application in the build image and then copy the .dll to a fresh image.
That would look aprox. like this:
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build
LABEL maintainer [email protected]
COPY /home/dejant/desktop/app /app
WORKDIR /app
RUN dotnet restore
RUN dotnet publish ./ParallelDemo/ParallelDemo.csproj -o /publish/
FROM mcr.microsoft.com/dotnet/core/sdk:2.2
COPY --from=build /THE/CORRECT/PATH/TO/YOUR/.DLL/LOCATION /app/ParallelDemo.dll
WORKDIR /app
ENTRYPOINT ["dotnet"]
CMD ["/app/ParallelDemo.dll"]
Upvotes: 1