Let us see how to automatically start Docker on Windows immediatly after start-up.
In order to do that, you just need to perform the following steps:

  1. Create a text file and rename it dockerAtStartup.ps1
  2. Add the following code:
    start-service -Name com.docker.service
    start C:\'Program Files'\Docker\Docker\'Docker Desktop.exe'
    

    NB: Don’t forget to write ‘Program Files’ instead of Program Files to cope with the space in the path. Do the same for ‘Docker Desktop.exe’.

  3. In the same folder, create a text file and rename it registerNewTask.ps1

  4. Add the following code:

    $trigger = New-ScheduledTaskTrigger -AtStartup
    $action = New-ScheduledTaskAction -Execute "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -Argument "-File C:\PowershellScripts\dockerAtStartup.ps1"
    $settings = New-ScheduledTaskSettingsSet -Compatibility Win8 -AllowStartIfOnBatteries
    Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "Launch Docker on Start up" -Settings $settings -User "Your user account" -Password "Your password" -RunLevel Highest
    try {
        Add-LocalGroupMember -Group docker-users -Member "Your user" -ErrorAction Stop
    }
        catch [Microsoft.PowerShell.Commands.MemberExistsException] {
    }
    
  5. Open you Powershell CLI as admin,

  6. Go to the folder where the scripts (“.ps1 files”) are located and run:
    cd C: ... to-the-folder-where-the-scripts-are-located...
    
  7. run:
    .\registerNewTask
    
  8. then:
    .\dockerAtStartup
    

    That is all, you have now you Docker launching automatically on start up.

Written by

Albert Oplog

Hi, I'm Albert Oplog. I would humbly like to share my tech journey with people all around the world.