I have a long running container deployed to Azure Container Instances where the time within the container must be accurate. The time drift when the container has been running for 24 hours can be as much as 7 seconds, this causing me a problem with my application running inside.
My docker container used to build the app is Microsoft's standard .NET 6 container definition. What is the best method of keeping a container in sync with the real time ? Do I have to install NTP somehow in my container ? Any help would be appreciated :)
Here is my Dockerfile:
RUN apt-get update && apt-get install -y libgdiplus
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["TradingBot.csproj", ""]
RUN dotnet restore "./TradingBot.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "TradingBot.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "TradingBot.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "TradingBot.dll"]```