Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Every container or host system reboot resets Windows network settings #161

Closed
itiligent opened this issue Jul 24, 2024 · 7 comments
Closed
Assignees
Labels
legacy Using legacy winapps windows Has to do with the guest OS

Comments

@itiligent
Copy link
Contributor

Every time the Windows docker container is either rebooted, or the host Linux system is restarted, the Windows network settings are not carried over at next boot requiring manual intervention to re-establish network groups and sharing.

Pictured is after the 4th reboot of my test container that built with the default compose file. Each reboot requires I log in interactively to reset this. Doe's anyone know what am I missing?

image

@KernelGhost
Copy link
Member

Hello, thank you for your interest in the project.

It seems that your question pertains to the behaviour of the Docker container itself, which would be best addressed by the dockur/windows team. If you decide to open an issue on their repository, please share the link here for the benefit of other users.

@KernelGhost KernelGhost self-assigned this Jul 25, 2024
@gordoncheong
Copy link
Contributor

gordoncheong commented Jul 25, 2024

Maybe this can help you?

Edit: This won’t carry over your settings, but at least it will suppress the prompt.

@LDprg LDprg added legacy Using legacy winapps windows Has to do with the guest OS labels Jul 28, 2024
@itiligent
Copy link
Contributor Author

itiligent commented Sep 16, 2024

For those still looking for a workaround:

  1. Stop the annoying prompt by adding this key:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\NewNetworkWindowOff]

  1. Set this script to run as a task at boot to keep the network profiles tidy (you will need to adapt it if you have multiple virutal NICs. It will remove any unused profiles and set the current network adatper name to "WinApps"
# Get the current network profile name
$currentProfile = (Get-NetConnectionProfile).Name

# Get all profiles from the registry
$profilesKey = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles"
$profiles = Get-ChildItem -Path $profilesKey

foreach ($profile in $profiles) {
    $profilePath = "$profilesKey\$($profile.PSChildName)"
    $profileName = (Get-ItemProperty -Path $profilePath).ProfileName

    # Remove profiles that don't match the current one
    if ($profileName -ne $currentProfile) {
        Remove-Item -Path $profilePath -Recurse
        Write-Host "Deleted profile: $profileName"
    }
}

# Change the current profile name to "WinApps"
$profiles = Get-ChildItem -Path $profilesKey
foreach ($profile in $profiles) {
    $profilePath = "$profilesKey\$($profile.PSChildName)"
    $profileName = (Get-ItemProperty -Path $profilePath).ProfileName

    if ($profileName -eq $currentProfile) {
        # Update the profile name
        Set-ItemProperty -Path $profilePath -Name "ProfileName" -Value "WinApps"
        Write-Host "Renamed profile to: WinApps"
    }
}

@oskardotglobal
Copy link
Member

@itiligent Can we set this script up as a boot task from inside installer.bat?

@itiligent
Copy link
Contributor Author

Yes, I was already looking at that yesterday. As a batch file it's not really workable, but it's possible to create the powershell script and call it as a scheduled task at boot all via the install.bat. I've built a time sync function as a scheduled task in install.bat already and it works OK. My install script only needs a little more adaptation for fedora but I've been short of time lately

@itiligent
Copy link
Contributor Author

itiligent commented Sep 18, 2024 via email

@oskardotglobal oskardotglobal linked a pull request Sep 18, 2024 that will close this issue
@itiligent
Copy link
Contributor Author

Solved in PR #259

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy Using legacy winapps windows Has to do with the guest OS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants