Skip to content

Instantly share code, notes, and snippets.

@pungoyal
Created March 17, 2020 03:41
Show Gist options
  • Save pungoyal/d235530f9ca4615b52f5c9e4715a02cc to your computer and use it in GitHub Desktop.
Save pungoyal/d235530f9ca4615b52f5c9e4715a02cc to your computer and use it in GitHub Desktop.
❯ cat ~/.config/fish/functions/update-docker.fish
function update-docker -d "pull latest images from docker"
docker ps -a
echo 'cleaning dead containers'
docker ps -a | sed '1d' | cut -d' ' -f1 | xargs docker rm -f
echo 'removing untagged images'
docker images -a | sed '1d' | grep none | awk '{print $3}' | xargs docker rmi
docker images -a
echo 'pulling latest image with tags'
docker images -a | sed '1d' | awk '{print $1":"$2}' | xargs -L1 docker pull
docker images -a | sed '1d' | grep none | awk '{print $3}' | xargs docker rmi
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment