diff --git a/helpful_tools/Install-DockerCE/install-docker-ce.ps1 b/helpful_tools/Install-DockerCE/install-docker-ce.ps1 index df0ff7a..205c200 100644 --- a/helpful_tools/Install-DockerCE/install-docker-ce.ps1 +++ b/helpful_tools/Install-DockerCE/install-docker-ce.ps1 @@ -411,6 +411,35 @@ Install-ContainerHost } } + # + # Install, register, and start Docker + # + if (Test-Docker-Version) + { + Write-Output "Docker is already installed with specific version." + } + else + { + if (Test-Docker) + { + #Stop all containers + docker stop $(docker ps -aq) + + #Halt the docker service + Stop-Service -Name docker + + #Unregister the docker service + dockerd --unregister-service + } + if ($NATSubnet) + { + Install-Docker -DockerPath $DockerPath -DockerDPath $DockerDPath -NATSubnet $NATSubnet -ContainerBaseImage $ContainerBaseImage + } + else + { + Install-Docker -DockerPath $DockerPath -DockerDPath $DockerDPath -ContainerBaseImage $ContainerBaseImage + } + } if ($TarPath) { cmd /c "docker load -i `"$TarPath`"" @@ -729,6 +758,16 @@ Test-Docker() } +function +Test-Docker-Version() +{ + $version = & docker version --format "{{.Server.Version}}" + Write-Host "Installed version:" $version + Write-Host "Target version:" $DockerVersion + return ($version -eq $DockerVersion) +} + + function Wait-Docker() { @@ -772,4 +811,5 @@ try catch { Write-Error $_ -} \ No newline at end of file +} +