Skip to content

Instantly share code, notes, and snippets.

@dieseltravis
Created February 8, 2020 07:36
Show Gist options
  • Save dieseltravis/85244257985daf3a9b8eb9cbbf309530 to your computer and use it in GitHub Desktop.
Save dieseltravis/85244257985daf3a9b8eb9cbbf309530 to your computer and use it in GitHub Desktop.
powershell version of docker_run.sh for pi-hole
# powershell version of:
# https://github.com/pi-hole/docker-pi-hole/blob/master/docker_run.sh
$ServerIP = (Get-NetIPConfiguration | Where-Object { $_.IPv4DefaultGateway -ne $null -and $_.NetAdapter.Status -ne "Disconnected" -and $_.InterfaceDescription -NotLike "*virtual*" } | Sort-Object InterfaceAlias | Select-Object -First 1).IPv4Address.IpAddress
docker run -d `
--name pihole `
-p 53:53/tcp -p 53:53/udp `
-p 80:80 `
-p 443:443 `
-e TZ="America/New York" `
-e WEBPASSWORD="password" `
-e DNS1="1.1.1.1" `
-e DNS2="1.0.0.1" `
-e ServerIP="$ServerIP" `
-v "./etc-pihole/:/etc/pihole/" `
-v "./etc-dnsmasq.d/:/etc/dnsmasq.d/" `
--dns=127.0.0.1 `
--dns=1.1.1.1 `
--restart=unless-stopped `
pihole/pihole:latest
Write-Host 'Starting up pihole container ' -NoNewline
for ($i=0; $i -le 20; $i++) {
$health = docker inspect -f "{{.State.Health.Status}}" pihole
if ($health -eq "healthy") {
Write-Host ' OK' -NoNewline
Write-Output "`n$(docker logs pihole 2> .\devnull.log | grep 'password:') for your pi-hole: https://$ServerIP/admin/"
exit 0
} else {
Start-Sleep 3
Write-Host '.' -NoNewline
}
if ( $i -eq 20 ) {
Write-Output "`nTimed out waiting for Pi-hole start, consult check your container logs for more info (``docker logs pihole``)"
exit 1
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment