Execute command on all running lxd containers

Home   »   Execute command on all running lxd containers

#!/bin/bash
set -o pipefail
set -e

for lxc in $(lxc list --format json | jq -r '.[] | select(.status == "Running").name');
do
       echo "Executing command on: $lxc"
       lxc exec $lxc -- hostname
       echo "============================"
done

Leave a Reply

Your email address will not be published. Required fields are marked *