Skip to content

Instantly share code, notes, and snippets.

@jotafeldmann
Created September 22, 2021 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jotafeldmann/2fd1f45d1f1bcf6fcc9d4e9f0afc36dc to your computer and use it in GitHub Desktop.
Save jotafeldmann/2fd1f45d1f1bcf6fcc9d4e9f0afc36dc to your computer and use it in GitHub Desktop.
Docker ZFS removal solution
# Docker solution for "removal of container X is already in progress"
# driver "zfs" failed to remove root filesystem: exit status 1: "/usr/sbin/zfs fs destroy -r rpool/"
# Based on https://github.com/moby/moby/issues/40132#issuecomment-570000174
docker ps -a | grep Removal | cut -f1 -d' ' | xargs -rt docker rm 2>&1 >/dev/null | grep "dataset does not exist" | awk '{print $(NF-4)}' | sed "s/'//g" | cut -f1 -d':' | xargs -L1 sh -c 'for arg do sudo zfs destroy -R "$arg"; sudo zfs destroy -R "$arg"-init ; sudo zfs create "$arg" ; sudo zfs create "$arg"-init ; ...; done' _ ; docker ps -a | grep Removal | cut -f1 -d' ' | xargs -rt docker rm 2>&1 >/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment