|
1 | 1 | name: 'Wait for Docker service (Windows)' |
2 | | -description: 'Ensure the Docker daemon is running on Windows runners. Attempts to start the service if needed.' |
| 2 | +description: > |
| 3 | + Ensure the Docker daemon is running on Windows runners. Attempts to start the service if needed. |
| 4 | + Workaround for https://github.com/actions/runner-images/issues/13729 |
3 | 5 |
|
4 | 6 | inputs: |
5 | 7 | timeout: |
6 | 8 | description: 'Maximum seconds to wait for the Docker service' |
7 | 9 | required: false |
8 | 10 | default: '120' |
| 11 | + start_after: |
| 12 | + description: 'Seconds to wait before forcefully starting the Docker service' |
| 13 | + required: false |
| 14 | + default: '30' |
9 | 15 |
|
10 | 16 | runs: |
11 | 17 | using: "composite" |
12 | 18 | steps: |
13 | 19 | - name: Wait for Docker service |
14 | 20 | run: | |
15 | 21 | $timeout = [int]"${{ inputs.timeout }}" |
| 22 | + $startAfter = [int]"${{ inputs.start_after }}" |
16 | 23 | $elapsed = 0 |
17 | | - $svc = Get-Service docker -ErrorAction SilentlyContinue |
18 | | - if ($svc -and $svc.Status -ne 'Running') { |
19 | | - Write-Host "Docker service status: $($svc.Status). Attempting to start..." |
20 | | - Start-Service docker -ErrorAction SilentlyContinue |
21 | | - } elseif (-not $svc) { |
22 | | - Write-Host "Docker service not found. Installed services:" |
23 | | - Get-Service *docker* | Format-Table -AutoSize |
24 | | - } |
| 24 | + $startAttempted = $false |
| 25 | +
|
25 | 26 | while ($elapsed -lt $timeout) { |
26 | 27 | $svc = Get-Service docker -ErrorAction SilentlyContinue |
27 | 28 | if ($svc -and $svc.Status -eq 'Running') { |
28 | 29 | Write-Host "Docker service is running." |
29 | 30 | docker version |
30 | 31 | return |
31 | 32 | } |
| 33 | +
|
| 34 | + if (-not $svc) { |
| 35 | + Write-Host "Docker service not found. Installed services:" |
| 36 | + Get-Service *docker* | Format-Table -AutoSize |
| 37 | + } |
| 38 | +
|
| 39 | + if ($elapsed -ge $startAfter -and -not $startAttempted) { |
| 40 | + if ($svc) { |
| 41 | + Write-Host "Docker not available after ${startAfter}s — starting the service (see https://github.com/actions/runner-images/issues/13729)" |
| 42 | + Start-Service docker -ErrorAction SilentlyContinue |
| 43 | + $startAttempted = $true |
| 44 | + } else { |
| 45 | + Write-Host "Docker service still not found after ${startAfter}s — will keep waiting for it to be registered." |
| 46 | + } |
| 47 | + } |
| 48 | +
|
32 | 49 | Write-Host "Waiting for Docker service... ($elapsed s) status: $(if ($svc) { $svc.Status } else { 'not found' })" |
33 | 50 | Start-Sleep 5 |
34 | 51 | $elapsed += 5 |
|
0 commit comments