Command | Description |
---|---|
sudo snap install lxd |
Install LXD |
lxd init |
Initialize LXD |
sudo usermod -aG lxd <user> |
Add user to the LXD group |
Command | Description |
---|---|
lxc remote list |
List remotes |
lxc image list images: |
List all images from the "images" remote |
lxc image list images: ubuntu amd64 |
Filter Ubuntu images for amd64 architecture |
lxc image info images:ubuntu/jammy |
Get detailed info about an image |
lxc image list local: |
List local images |
lxc image list |
List all available images |
lxc image copy images:debian/12 local: --auto-update --copy-aliases |
Copy Debian 12 image to local with auto-update |
lxc image copy ubuntu:jammy local: --auto-update --alias ubuntu/24.04 |
copy to local with spesific aliases |
Command | Description |
---|---|
lxc launch images:ubuntu/focal ubuntu |
Launch a container with Ubuntu Focal |
lxc launch images:alpine/3.16 alpine |
Launch a container with Alpine 3.16 |
lxc list |
List running and stopped containers |
Command | Description |
---|---|
lxc exec ubuntu hostname |
Execute a command in the container |
lxc exec ubuntu -- hostname |
Alternative syntax |
lxc shell ubuntu |
Get a shell inside the container |
lxc console ubuntu |
Access container console (Ctrl+A, then Q to exit) |
lxc file edit ubuntu/home/david/.bashrc |
Edit a file inside the container |
Command | Description |
---|---|
lxc start ubuntu |
Start a container |
lxc stop ubuntu |
Stop a container |
lxc restart ubuntu |
Restart a container |
Command | Description |
---|---|
lxc snapshot ubuntu snap1 |
Create a snapshot |
lxc snapshot ubuntu snap2 |
Create another snapshot |
lxc delete ubuntu/snap1 |
Delete a specific snapshot |
lxc restore ubuntu snap2 |
Restore to a specific snapshot |
Command | Description |
---|---|
lxc config set ubuntu boot.autostart 1 |
Enable autostart for the container |
lxc config set ubuntu boot.autostart.delay 30 |
Set autostart delay (in seconds) |
lxc config set ubuntu boot.autostart.order 2 |
Set autostart order |
lxc config set ubuntu limits.memory 1GB |
Set memory limit for the container |
lxc config show ubuntu |
Show container configuration |
Command | Description |
---|---|
lxc info ubuntu |
Get detailed info about the container |