Lxd: Support deleting multiple containers at once (possibly all)

Created on 29 Apr 2015  路  10Comments  路  Source: lxc/lxd

It'd be nice to just clean up all the containers on a machine with something like lxc delete * or lxc delete -a (or something similar.)

Feature

Most helpful comment

@miathedev Nothing like that has been added. You can however delete all container by running lxc rm -f $(lxc ls -c n --format csv). No external tools needed.

All 10 comments

I think it'd be better instead to just allow multiple container names in the delete line

lxc delete host:c1 c2 c5 that way the action is more explicit to avoid accidental deletions.

FTR, uvt-kvm currently does what Marco says, which also means that uvt-kvm list|xargs uvt-kvm destroy works. It doesn't currently support * or -a but I'm not too opposed to that. I favour -a since the * would need escaping and \* is more awkward than -a.

Supporting multiple container names would be fine with me, we may want to consider what other command would benefit from a similar behavior (for consistency).

I think that this would be best for delete, start, stop and restart

when issueing the command sudo lxc delete * i just get an "error: not found"

though, any name i give it, even if its a legic lxd container, says its not found.

you can write a one liner for it. Replace destroy with any other command.
lxc-destroy $(lxc-ls|awk 'NR==1{print $1}')

Was there something added like lxc delete all ?
Im a little bit frustrated deleting > 100 containers by hand now - i would prefer to go to bed now if i could...
awk and grep is not available on my host...

@miathedev Nothing like that has been added. You can however delete all container by running lxc rm -f $(lxc ls -c n --format csv). No external tools needed.

you can use :
for i in $(lxc-ls) ; do lxc-stop $i; done
for i in $(lxc-ls) ; do lxc-destroy $i; done

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kp3nguinz picture kp3nguinz  路  5Comments

jsnjack picture jsnjack  路  3Comments

spacekookie picture spacekookie  路  3Comments

iteco picture iteco  路  3Comments

sajoupa picture sajoupa  路  4Comments