lxd
Table of Contents
1. Information
1.1. Instance
lxc info <instance_name> # shows more info like effective interfaces etc. lxc config show <instance_name> -e # existing instance config lxc list -f csv -c n | fzf |xargs lxc info
1.2. Global config
lxc config show
1.3. Profile
lxc profile list lxc profile show <profile_name>
1.4. Images
lxc remote list # lists all image servers lxc image list <remote_name>:<search term, eg. ubuntu>
2. Create
lxc (launch|init) images:ubuntu/22.04 <instance_name> # readonly props cannot be changed after creation lxc launch images:ubuntu/22.04 <instance_name> < config.yaml # using a config file
3. Modify
lxc config device set <instance_name> <device_name> <dev_opt_k>=<dev_opt_v>.. lxc config edit <instance_name> # NOTE: this also shows readonly keys, changes to readonly keys are ignored
4. Delete
4.1. Instance
lxc delete <instance_name> # What happens to storage? lxc list -f csv -c n | xargs lxc delete --force # delete all containers, including running
4.2. Storage
lxc profile edit <profile_name> # remove the storage from the profile lxc storage delete <storage_name>
5. Exec
lxc exec <instance_name> -- <command> # by default, runs root(UID0) and WD set to /root
5.1. Login
lxc exec <instance_name> -- /bin/bash lxc exec <instance_name> -- su --login <user_name>
w alias:
lxc alias add login 'exec @ARGS@ --mode interactive -- bash -xc {exec,login,-p,-f,$USER}'
lxc login <instance_name> lxc login <instance_name> --env USER=ubuntu
6. Sharing
lxc file pull <instance>/<path> <path_on_host> # get file from instance