Skip to content

Instantly share code, notes, and snippets.

@sixeyed
Last active March 17, 2023 19:30
Show Gist options
  • Save sixeyed/adce79b18c5f572feaf34ae9e90513c2 to your computer and use it in GitHub Desktop.
Save sixeyed/adce79b18c5f572feaf34ae9e90513c2 to your computer and use it in GitHub Desktop.
PowerShell aliases for working with Docker on Windows - save to $profile
#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