Is there a way to gracefully shut-down a DOTNET CORE application which is running in DOCKER? If yes, which event I should listen?
All I want is upon cancellation request I would like to pass my cancellation token/s to current methods and postpone the shut-down while they are working.
Looking for a sample code, reference link etc. which are relevant to dotnet core and not generic info
UPDATE This question is not a duplicate of docker container exits immediately even with Console.ReadLine() in a .net core console application because I'm not having an immediate exit issue. I need to tap into event something like Windows.SystemsEvents.SessionEnding and relying on
Console.CancelKeyPress
and/or implementingWebHostBuilder()
doesn't fit the bill.
docker rm -f The final option for stopping a running container is to use the --force or -f flag in conjunction with the docker rm command. Typically, docker rm is used to remove an already stopped container, but the use of the -f flag will cause it to first issue a SIGKILL.
NET Core Docker images are published to the Microsoft Container Registry (MCR) and are discoverable at the Microsoft . NET Core Docker Hub repository. Each repository contains images for different combinations of the . NET (SDK or Runtime) and OS that you can use.
In .NET Core 2.0, you can use the AppDomain.CurrentDomain.ProcessExit
event, which works fine on Linux in Docker. AssemblyLoadContext.Default.Unloading
probably works as well, even before .NET Core 2.0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With