alpine docker image with dotnet doesn't see my app

Viewed 1069

I'm trying to run my dotnet 5 single file app with Alpine Linux docker image. This is my Dockerfile

FROM mcr.microsoft.com/dotnet/aspnet:5.0-alpine    
WORKDIR /app
COPY ["Service.Translations", "/app/Service.Translations"]

CMD ["./Service.Translations", "--urls", "http://0.0.0.0:5000"]

This was framework-dependent app. Also tried with self-contained and result is the same: not found. Dotnet doesn't see my file and sh doesn't see too.

Is it problem because I built my app on Windows? All tutorials with alpine compile app inside image. If I change Alpine to Ubuntu or smth else - everything is ok.

UPDATE: Ok, problem was with publish. I had to change --runtime to linux-musl-x64 instead of linux-x64

1 Answers

I found the problem. Alpine Linux uses musl c library and it makes standard dotnet build incompatible with this linux distro. Visual studio doesn't have all publish runtime options. Here https://docs.microsoft.com/en-us/dotnet/core/rid-catalog you can find all of them. So for alpine linux we have to use linux-musl-x64 runtime instead of linux-x64

Related