LXD LXC

Updated: 05 December 2025

See https://canonical.com/lxd
Support https://discuss.linuxcontainers.org/

List instances

lxc ls

List instances in longer json format

lxc list --format=json | jq

Start instance win11 and immediately attach to the console

lxc start win11 --console=vga

Prevent a container from automatically starting whenever the LXD host starts

lxc config set the_container boot.autostart false

Stop the instance called win11, with force

lxc stop --force win11

Delete container win11

lxc delete win11

Enter a container as user sammy

lxc exec the_container -- su sammy

lxc launch

Start a container

lxc launch ubuntu:24.04

Start a virtual machine

lxc launch ubuntu:24.04 --vm

Start a NixOS virtual machine (credit)

lxc launch images:nixos/25.05 --vm nix

Snapshots

Create a snapshot of a container

lxc snapshot container_name snapshot_name

Show a list of available snapshots

lxc info container_name

Select and restore a snapshot

lxc restore container_name snapshot_name

Delete a snapshot

lxc delete win11d/the_first_shot

Devices

Remove a device e.g. iso CD

lxc config device remove container_name name_of_device

Networking

Hit host IP address from inside a LXC container, assuming container uses lxdbr0 attached to same network as host

# Get IP of host.
curl ifconfig.me

# From container curl for http service running on host port 80.
# IPv6 version address in this case.
curl -6 http://[2401:d800:3f1:ba7b:f02c:a795:f128:864]