Unfortunately, I still cannot see whether the user rights are set correctly in the Task Scheduler.
After clicking on OK you have to enter the user’s password.
But the situation is similar for me, even with correctly set user rights. So I tried a bit.
In my case, the distributions “docker-desktop” and “docker-desktop-data” for WSL 2 do not start.
So I also tried to start them via the Task Scheduler before Docker Desktop
C:\Windows\system32\wsl.exe -d docker-desktop
C:\Windows\system32\wsl.exe -d docker-desktop-data
C:\Program files\Docker\Docker\Frontend\Docker Desktop.exe
With the command “wsl -l -v” I could see that the distros were still stopped after starting Windows.
Therefore it does not work. Unfortunately I have no error message to find out why.
For this reason I have disabled WSL 2 in Docker Desktop.
Via the Task Scheduler I just started the program “C:\Program Files\Docker\Docker\Frontend\Docker Desktop.exe”
After that it worked for me.
I tested it with a web server running in a Docker container.
However, it should also be mentioned that the graphical user interface cannot be started if Docker Desktop has been started via the Task Scheduler, as it is already running in the background.
Normally, scheduled tasks run as background processes. However, according to the following instructions from Microsoft, you can set tasks to run interactively.
Unfortunately, this option is not available in the Windows Task Scheduler, but with the At Utility. But I don’t know if you can run a task on startup with the At Utility. Maybe someone can give me a hint.
It is also possible to import an XML file as a task into the Task Scheduler. Login to Windows with the user account that is a member of the “docker-users” group. Start the Task Scheduler and import the XML file. Change the user in the task to the same user who is logged in. After clicking on OK you have to enter the user’s password (not the Windows Hello PIN).
First of all, create an XML file with the name “Docker Desktop Autostart.xml” and the following content:
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2024-04-02T07:27:45.4363167</Date>
<Author>bluenobly</Author>
<URI>\Docker Desktop Autostart</URI>
</RegistrationInfo>
<Triggers>
<BootTrigger>
<Enabled>true</Enabled>
</BootTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>S-0-0-0-00000000-00000000-00000000-0000</UserId>
<LogonType>Password</LogonType>
<RunLevel>HighestAvailable</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>"C:\Program files\Docker\Docker\Frontend\Docker Desktop.exe"</Command>
</Exec>
</Actions>
</Task>
TaskSettings: TaskSettings object - Win32 apps | Microsoft Learn
And don’t forget to deactivate WSL 2 in the Docker Desktop.