LXC Containers Cheatsheet
#
LXC (Linux Containers) provides a lightweight virtualization method to run multiple Linux systems on a single host.
Container Management
#
Command/Option | Example | Description |
---|
lxc-create | lxc-create -t ubuntu -n mycontainer | Create a new container with the specified template and name |
lxc-start | lxc-start -n mycontainer | Start the specified container |
lxc-stop | lxc-stop -n mycontainer | Stop the specified container |
lxc-destroy | lxc-destroy -n mycontainer | Destroy the specified container |
lxc-info | lxc-info -n mycontainer | Display information about the specified container |
Container Configuration
#
Command/Option | Example | Description |
---|
lxc-config | lxc-config -l | List all configuration options for LXC |
lxc-profile | lxc-profile -n mycontainer | View or modify the profile of a container |
Networking
#
Command/Option | Example | Description |
---|
lxc-net | lxc-net -a 10.0.3.1 -g 10.0.3.0/24 | Configure network settings for LXC containers |
lxc-network | lxc-network -n mycontainer | Display network configuration for a specific container |
Container Filesystem
#
Command/Option | Example | Description |
---|
lxc-execute | lxc-execute -n mycontainer -- bash | Execute a command inside the container |
lxc-attach | lxc-attach -n mycontainer | Attach to a running container |
Container Monitoring
#
Command/Option | Example | Description |
---|
lxc-ls | lxc-ls | List all containers on the host |
lxc-top | lxc-top | Display resource usage of running containers |
lxc-cgroup | lxc-cgroup -n mycontainer | Manage cgroup settings for a specific container |
Snapshot Management
#
Command/Option | Example | Description |
---|
lxc-snapshot | lxc-snapshot -n mycontainer | Create a snapshot of a container |
lxc-snapshot -l | lxc-snapshot -l | List all snapshots for containers |
Other Commands
#
Command/Option | Example | Description |
---|
lxc-config | lxc-config -l | List all configuration options for LXC |
lxc-start | lxc-start -n mycontainer -d | Start the container in the background |
This cheatsheet covers essential LXC container commands and options to help you manage and maintain LXC containers effectively.