How to start Docker daemon (windows service) at startup without the need to log-in?

前端 未结 4 1550
遇见更好的自我
遇见更好的自我 2020-12-25 13:50

We have Docker for Windows installed on a Windows Server 2016 Datacenter box.

We use this box as a build agent for our docker containers.

When we try to conn

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-25 14:36

    Here's a PowerShell script that creates the scheduled task and is verified to work on Windows 10:

    $trigger = New-ScheduledTaskTrigger -AtStartup
    $trigger.Delay = 'PT1M'
    
    $action = New-ScheduledTaskAction -Execute 'C:\Program Files\Docker\Docker\Docker Desktop.exe'
    
    $settings = New-ScheduledTaskSettingsSet -Compatibility Win8 -StartWhenAvailable -RestartCount 999
    $settings.ExecutionTimeLimit = 'PT0S'
    $settings.RestartInterval = 'PT1M'
    
    Register-ScheduledTask -Action $action -Trigger $trigger -TaskName Docker -Settings $settings -User docker -Password (ConvertFrom-SecureString (Read-Host -Prompt 'Password' -AsSecureString) -AsPlainText)
    

提交回复
热议问题