Quick tip - delete all LXD containers hosting juju

The following shell command deletes all containers that start with the name juju:

lxc list --format=csv --columns=n juju | xargs lxc delete --force 
2 Likes

For some reason the profile list in lxc doesn’t have a format flag, so you have to do some jumping through hoops to remove all the profiles…

lxc profile list | grep juju | tr -s ' ' | cut -d ' ' -f 2 | xargs -I % echo "lxc profile delete %" | sh

Sounds like a useful issue to file with github.com/lxc/lxd

TBH: I could just file a PR in my spare time :wink:

To be fair, there should still be a bug you’re working against if you were to put up a PR. :slight_smile:

1 Like