Automatic Gracefull DOCKER container SHUTDOWN on SYSTEM Restart/Shutdown (SYSTEM OS)

I appreciate the insight and the reply. Still learning how all of this stuff works.

Once I figure out how to get my DB container to shut down gracefully I’ll update this thread with what I tried.

Update:

Couldn’t figure out how to gracefully shut down the process from the entrypoint script unfortunately. Tried to trap the shutdown signals in my powershell script but it wouldn’t trigger. Not sure how else I could ‘intercept’ that and run my own shutdown commands without directly modifying the apps source and recompiling.

I ended up just using an IIS image to pull servicemonitor.exe and installed the service instead of just running the process. Looking at the logs its finally gracefully shutting down. Dockerfile syntax if anyone is wondering:

FROM mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2022 AS iis
FROM mcr.microsoft.com/windows/servercore:ltsc2022
COPY --from=iis /ServiceMonitor.exe /ServiceMonitor.exe

Whether the container will have >5 seconds to terminate is a different story though. Going to keep testing. Hopefully someone finds this info useful.

1 Like