Skip to content

Instantly share code, notes, and snippets.

@lcherone
Created September 20, 2017 04:30
Show Gist options
  • Save lcherone/c5a6cd57092f9b69cd20affad1f3e5ee to your computer and use it in GitHub Desktop.
Save lcherone/c5a6cd57092f9b69cd20affad1f3e5ee to your computer and use it in GitHub Desktop.
LXD run command in all running containers
#!/bin/bash
#
# Run command in all running containers
# Usage: $ ./lxc-exec-all.sh apt update && apt upgrade
#
for container in $(lxc list volatile.last_state.power=RUNNING -c n --format csv); do
lxc exec "$container" "$@"
done
@doug65536
Copy link

doug65536 commented Dec 14, 2021

Should put -- before "$@" so it won't confuse things for lxc options. Super helpful gist though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment