Bash Completions, Aliases and Functions for working with LXC (not LXD, just plain LXC)
Source the completion file in your .bashrc:
source /path/to/lxc-bash-completion.bash| Command | Description |
|---|---|
lxc-ls |
List all containers with full info |
lxc-start <name> |
Start a stopped container |
lxc-stop <name> |
Stop a running container |
lxc-shutdown <name> |
Gracefully shutdown via poweroff |
lxc-attach <name> [user] |
Attach to container (auto-starts if stopped) |
lxc-info <name> |
Show container info |
lxc-ip <name> |
Get container IP address |
lxc-freeze <name> |
Freeze a running container |
lxc-unfreeze <name> |
Unfreeze a frozen container |
lxc-start-debug <name> [logfile] |
Debug container startup failures |
All commands support tab completion for container names.
When a container fails to start, lxc-start automatically offers to run debug mode (interactive terminals only). You can also run it directly:
lxc-start-debug mycontainerThis will:
- Run pre-flight checks (bridge, IPv6 config, config/rootfs)
- Offer to restart services (e.g.,
lxc-net) with failure diagnosis - Attempt foreground start to capture detailed errors
- Analyze output and suggest fixes
- Offer to retry after fixes
Common issues detected:
- Missing bridge (
lxcbr0) - offers to restartlxc-net - IPv6 disabled - detects when system has IPv6 disabled but lxc-net expects it
- Permission denied - checks for AppArmor/SELinux issues
- Network/cgroup problems - with specific fix suggestions
Optionally save debug output to a file:
lxc-start-debug mycontainer /tmp/debug.log