[lxc-users] Wildcard in lxd commands?
zztest at openmailbox.org
zztest at openmailbox.org
Thu Mar 17 21:55:55 UTC 2016
On 2016-03-17 07:07, Mark Constable wrote:
> On 17/03/16 23:01, Janne Savikko wrote:
>> You can not use filters to list running or stopped containers. Lxc
>> start or stop do not support filters, only container name (or names).
>> You though can always pipe commands if you want to stop dozens of
>> containers whose names begin with "web" (note! lxc list keyword
>> filter compares from the start of the name, so "lxc list eb" does not
>> work in this case):
>>
>>
>> $ lxc list web|grep RUNNING|awk '{ print $2 }'|xargs lxc stop
>
> It's still rather awkward to reliably script a start/stop of a single
> container that happens to be called "web" when there might be web1,
> web2 etc. An explicit non-filtered arg to lxc list with optional regex
> would be more useful. Plus an option to have plain non-tablewriter
> output for easier script parsing.
>
> [[ `lxc list -cs web` = RUNNING ]]; echo $?
>
> _______________________________________________
> lxc-users mailing list
> lxc-users at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-users
I agree. lxc list would be immensely useful if it could output just a
list of names or other single attribute of containers that match
particular criteria. That could then be fed to a command. Something easy
to remember like:
lxc list -cn --name=web* --state=running | lxc stop {}
More information about the lxc-users
mailing list