2.8 KiB
2.8 KiB
LXC CLI Cheatsheet
Container Management
- Usage: Useful for day-to-day container management tasks like checking container status, executing commands inside containers, and getting detailed information.
lxc list -c n,s,4,image.description:image
Description: Lists containers with specific columns like name, state, IPv4 address, and image description.lxc info <container-name>
Description: Displays detailed information about a specific container.
Example:lxc info mycontainerlxc exec <container-name> -- <command>
Description: Executes a command inside the specified container.
Example:lxc exec mycontainer -- bash
Image Management
- Usage: Important for understanding what images are available and for selecting the right image for container deployment.
lxc image list
Description: Lists all available images.lxc image alias list <repository>: <tag>
Description: Lists all aliases for an image in a repository.
Example:lxc image alias list ubuntu: '20.04'
Networking
- Usage: Essential for setting up and troubleshooting container networking, ensuring containers can communicate with each other and the outside world.
lxc network list
Description: Lists all networks.lxc network show <network-name>
Description: Shows detailed information about a specific network.
Example:lxc network show lxdbr0
Advanced Container Operations
- Usage: Advanced features that allow for more complex container management, like cloning containers, and managing container states and backups.
lxc launch <image-name>
Description: Launches a new container from the specified image.
Examples:lxc launch ubuntu:20.04,lxc launch images:alpine/3.13lxc copy <source-container> <destination-container>
Description: Copies a container to a new container.lxc snapshot <container-name>
Description: Creates a snapshot of a container.lxc restore <container-name> <snapshot-name>
Description: Restores a container from a specified snapshot.
File Management
- Usage: Useful for deploying configuration files or scripts inside containers.
lxc file push <source-path> <container-name>/<destination-path>
Description: Pushes a file from the host to the container.
Troubleshooting and Help
- Usage: Crucial for diagnosing and resolving issues with containers and processes.
lxc --help
Description: Displays help for LXC commands.ps -ef | grep <process-name>
Description: Finds processes related to a specific name, useful for troubleshooting.
Example:ps -ef | grep dnsmasq
Note: Replace placeholders like
<container-name>,<network-name>, and<image-name>with actual names when using the commands.