I’m confused about using dockerfile for situation where certain RUN actions require reboot of OS to complete. Example is below is trying to uninstall Windows-Defender-Features which never works as a result of it.
Docker file
from microsoft/iis
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'Continue'; $verbosePreference='Continue';"]
RUN Remove-WindowsFeature -Name Windows-Defender-Features -Confirm:$false
Result
PS C:\gd\test> docker exec a0 powershell -c get-windowsfeature windows-defender-features
Display Name Name
------------ ----
[X] Windows Defender Features Windows-Defender-Fea...
I don’t need it to be running since we are running our inhouse AV on host or may be our company want to use different AV product. Also I don’t think it’s really important which specific feature requires reboot since question how to do this in general is important to know
Yes when you create the first container the feature show as correctly uninstalled.
I did not yet tested if the same behavior occupare using the original command in the thread.
I assume that since the command is marked as removed in the build when you start the container for the first time it will interpreted as a restart.
This worked. Concern is that system seems to be left in “PendingReboot” state. “Get-WindowsFeature” returns some errors. Windows Defender service is still present but in stopped “State”. I really hope docker and Microsoft will have some discussion how to handle situations like this where reboot is required as part of dockerfile build.
How do I do that? System upon boot thinks of itself as “pending reboot” and this condition persists accross reboots since it’s never actually completes tasks Windows planned to perform upon reboot.