I am trying to run a .Net 5 application in an docker container. This Application uses the SAP NetWeaver RFC SDK to connect to a SAP system. However it reports the error
At first I tried to use the microsoft provided runtime image (mcr.microsoft.com/dotnet/runtime:5.0) which produced the error initially.
Inital docker file
FROM mcr.microsoft.com/dotnet/runtime:5.0 AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
# copy everything
Copy . .
WORKDIR "/src/SapClientService"
RUN dotnet restore
RUN dotnet build -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "SapClientService.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
ENV LD_DEBUG="all"
ENV LD_DEBUG_OUTPUT="/debug.txt"
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "SapClientService.dll"]
I then tried to modify the runtime images by installing the runtime myself, so that I can install packages and so on.
ARG DOTNET_VERSION=5.0.8
FROM amd64/ubuntu:focal as runtime-deps
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates \
\
# .NET Core dependencies
libc6 \
libgcc1 \
libgssapi-krb5-2 \
libicu66 \
libssl1.1 \
libstdc++6 \
zlib1g \
uuid \ # <- I added this
&& rm -rf /var/lib/apt/lists/*
ENV \
# Configure web servers to bind to port 80 when present
ASPNETCORE_URLS=http://+:80 \
# Enable detection of running in a container
DOTNET_RUNNING_IN_CONTAINER=true
# Installer image
FROM amd64/buildpack-deps:focal-curl as runtime-installer
ARG DOTNET_VERSION
# Retrieve .NET
RUN curl -SL --output dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Runtime/$DOTNET_VERSION/dotnet-runtime-$DOTNET_VERSION-linux-x64.tar.gz \
&& dotnet_sha512='8789609f3039dca1d0dc19562f23bc9bfe5d513a2d10639a8a779afe7656447b7ee953f9a8d9d0b07ba6ca4a346770c0efb5a34e5240b5d355d4d8198220e9b1' \
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \
&& mkdir -p /dotnet \
&& tar -ozxf dotnet.tar.gz -C /dotnet \
&& rm dotnet.tar.gz
# .NET runtime image
FROM runtime-deps as runtime
ARG DOTNET_VERSION
ENV DOTNET_VERSION=$DOTNET_VERSION
COPY --from=runtime-installer ["/dotnet", "/usr/share/dotnet"]
RUN ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
# copy everything
Copy . .
WORKDIR "/src/SapClientService"
RUN dotnet restore
RUN dotnet build -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "SapClientService.csproj" -c Release -o /app/publish
I used the content of the ms-runtime-deps and ms-runtim dockerfiles as a base.
I tried installing the package uuid
(which worked) but the uuidd
still is not accesible.
So the central question would be where do I get this uuidd
deamon from and how do I install/setup/start it.
I figured out what we need to do.
We need to install the packages uuid
and uuid-runtime
. And before we can start the uuidd
we need to create the folder /run/uuidd
by simply executing mkdir /run/uuidd
.
At first I though I only need the package uuid-runtime
and the folder /run/uuidd
since I could start the deamon without a problem. But as soon the NetWeaver code wants a uuid
the runtime totally crashes and I mean totally, it does not even output any errors.
So my Dockerfile
looks now like this
FROM mcr.microsoft.com/dotnet/runtime:5.0 AS base
RUN mkdir /run/uuidd
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
# SAP NetWeaver RFC SDK dependencies
\
uuid \
uuid-runtime \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
# copy everything
Copy . .
WORKDIR "/src/SapClientService"
RUN dotnet restore
RUN dotnet build -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "SapClientService.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT [ "sh", "-c", "uuidd && exec dotnet SapClientService.dll" ]
and works well.
The last thing to not is the
ENTRYPOINT [ "sh", "-c", "uuidd && exec dotnet SapClientService.dll" ]
we have to start the uuidd
manually and since docker seems to only want one start program we simply use sh
to start uuidd
and then our app. The exec
however is important according to the docker-docs.