Capturing an exit/shutdown of Windows Container via PowerShell

Hi All,

Struggling a little bit with the delights of windows and powershell.

Essentially what I am trying to achieve is to perform an action when the docker stop is called, or if the container exits badly. I am able to achieve this via trap in bash but when i attempt to use Try...Catch...Finally blocks in PoSH it doesn’t respect the Catch or Finally.

Just seeking some advice on how I could best get the script to execute on Finally. I am using a powershell script as my entrypoint currently.



1 Like

I am having exactly the same problem. The finally block is not executed when I stop the container.
I am running a Windows Container