Last active
March 17, 2023 19:30
-
-
Save sixeyed/adce79b18c5f572feaf34ae9e90513c2 to your computer and use it in GitHub Desktop.
PowerShell aliases for working with Docker on Windows - save to $profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#docker rm $(docker ps -a -q) | |
function Remove-StoppedContainers { | |
foreach ($id in & docker ps -a -q) { | |
& docker rm $id } | |
} | |
#docker rmi $(docker images -f "dangling=true" -q) | |
function Remove-DanglingImages { | |
foreach ($id in & docker images -q -f 'dangling=true') { | |
& docker rmi $id } | |
} | |
#docker volume rm $(docker volume ls -qf dangling=true) | |
function Remove-DanglingVolumes { | |
foreach ($id in & docker volume ls -q -f 'dangling=true') { | |
& docker volume rm $id } | |
} | |
# docker inspect --format '{{ .NetworkSettings.Networks.nat.IPAddress }}' <id> | |
function Get-ContainerIPAddress { | |
param ( | |
[string] $id | |
) | |
& docker inspect --format '{{ .NetworkSettings.Networks.nat.IPAddress }}' $id | |
} | |
New-Alias drm Remove-StoppedContainers | |
New-Alias drmi Remove-DanglingImages | |
New-Alias drmv Remove-DanglingVolumes | |
New-Alias dip Get-ContainerIPAddress |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment