0

I have a dotnet project that work when i do dotnet run, i am trying to containerize that dotnet project. For that i have create the Dockerfile as below:

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1

COPY bin/Release/netcoreapp3.1/publish/ App/
WORKDIR /App

EXPOSE 5000

CMD ["dotnet", "MediatorAgent.dll"]

Before creating the docker image i did run dotnet publish -c Release. Now when i try to run this docker image, i am getting the below error

Unhandled exception. System.DllNotFoundException: Unable to load shared library 'indy' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libindy: cannot open shared object file: No such file or directory

I am following the instruction for Containerize a .NET Core app for creating docker image.

Stefan
  • 17,448
  • 11
  • 60
  • 79
yatharth meena
  • 369
  • 4
  • 13

2 Answers2

2

How to create docker image for dotnet app?

Well, you did it.

What is likely to have gone wrong is that the DLL refered to as indy is not copied to the App folder.

Since you are copying the data, please verify it's included in the original build at bin/Release/netcoreapp3.1/publish

Stefan
  • 17,448
  • 11
  • 60
  • 79
  • I did add this libindy.so file to bin/Release/netcoreapp3.1/publish folder, but still getting the same issue. Earlier dotnet run wasnt working so i did sudo apt-get install -y libindy, this added libindy.so in /usr/lib so i copied that libindy.so to publish folder – yatharth meena Oct 09 '20 at 11:43
  • Ok, so - you are able to run it locally on your machine I suppose. Compare the output debug folder with the output publish folder and see if there is a file in the debug folder, but not in the publish folder. In 99% of all cases this is due to the missing of the specific file. How did you referenced the file in your project? – Stefan Oct 09 '20 at 12:36
0

make sure bin/Release/ directory available in the same directory where your Dockerfile exist.

You can specify the project .csproj or .sln to build.

You can have a look on below dockerfile, hope that will help you.

FROM microsoft/aspnetcore-build AS builder
WORKDIR /source

COPY projectname.csproj .
RUN dotnet restore
RUN dotnet build projectname.csproj -c Release -o /app/build

COPY . .
RUN dotnet publish -c Release -o /app/publish

FROM microsoft/aspnetcore
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "projectname.dll"]
Deepak Sharma
  • 331
  • 3
  • 11