diff --git a/eng/common/testproxy/docker-start-proxy.ps1 b/eng/common/testproxy/docker-start-proxy.ps1 index 4137ae2aff569..577af6d24d87c 100644 --- a/eng/common/testproxy/docker-start-proxy.ps1 +++ b/eng/common/testproxy/docker-start-proxy.ps1 @@ -64,9 +64,31 @@ if ($Mode -eq "start"){ } # else we need to create it else { + $attempts = 0 Write-Host "Attempting creation of Docker host $CONTAINER_NAME" Write-Host "docker container create -v `"${root}:${Initial}/etc/testproxy`" $LinuxContainerArgs -p 5001:5001 -p 5000:5000 --name $CONTAINER_NAME $SelectedImage" - docker container create -v "${root}:${Initial}/etc/testproxy" $LinuxContainerArgs -p 5001:5001 -p 5000:5000 --name $CONTAINER_NAME $SelectedImage + while($attempts -lt 3){ + docker container create -v "${root}:${Initial}/etc/testproxy" $LinuxContainerArgs -p 5001:5001 -p 5000:5000 --name $CONTAINER_NAME $SelectedImage + + if($LASTEXITCODE -ne 0){ + $attempts += 1 + Start-Sleep -s 10 + + if($attempts -lt 3){ + Write-Host "Attempt $attempts failed. Retrying." + } + + continue + } + else { + break + } + } + + if($LASTEXITCODE -ne 0){ + Write-Host "Unable to successfully create docker container. Exiting." + exit(1) + } } Write-Host "Attempting start of Docker host $CONTAINER_NAME" diff --git a/eng/common/testproxy/test-proxy-docker.yml b/eng/common/testproxy/test-proxy-docker.yml index 97617b6fd08a7..e4e4b2c8cdb0d 100644 --- a/eng/common/testproxy/test-proxy-docker.yml +++ b/eng/common/testproxy/test-proxy-docker.yml @@ -6,6 +6,10 @@ steps: $(Build.SourcesDirectory)/eng/common/scripts/trust-proxy-certificate.ps1 displayName: 'Language Specific Certificate Trust' + - pwsh: | + docker info + displayName: 'Dump active docker information' + - pwsh: | $(Build.SourcesDirectory)/eng/common/testproxy/docker-start-proxy.ps1 -Mode start -TargetFolder "${{ parameters.rootFolder }}" displayName: 'Run the docker container'