Files
the_information_nexus/tech_docs/pct.md
2024-05-01 12:28:44 -06:00

3.0 KiB

Container Creation

  • Create a new container:

    pct create <vmid> <ostemplate> [OPTIONS]
    
    • <vmid>: The ID of the new container (integer).
    • <ostemplate>: The path or name of the OS template to use for the container.
  • Example:

    pct create 101 /var/lib/vz/template/cache/openwrt-rootfs.tar.xz --unprivileged 1 --arch amd64 --ostype unmanaged --hostname openwrt-0 --storage local-lvm --net0 name=eth0,bridge=vmbr0,firewall=1 --net1 name=eth1,bridge=vmbr1,firewall=1
    

Container Management

  • Start a container: pct start <vmid>
  • Stop a container: pct stop <vmid>
  • Restart a container: pct restart <vmid>
  • Shutdown a container: pct shutdown <vmid>
  • Destroy a container: pct destroy <vmid>
  • Clone a container: pct clone <vmid> <newvmid>
  • Migrate a container: pct migrate <vmid> <target-node>
  • Resize a container's disk: pct resize <vmid> <disk> <size>

Container Configuration

  • Update container configuration: pct config <vmid> [OPTIONS]
  • Set container description: pct set <vmid> --description <text>
  • Set container memory: pct set <vmid> --memory <size>
  • Set container CPU cores: pct set <vmid> --cores <number>
  • Set container boot order: pct set <vmid> --boot <order>
  • Add a network device: pct set <vmid> --net<N> name=<name>,bridge=<bridge>,firewall=<1|0>
  • Add a mount point: pct set <vmid> --mp<N> <volume>

Container Snapshots

  • Create a snapshot: pct snapshot <vmid> <snapname>
  • List snapshots: pct listsnapshot <vmid>
  • Restore a snapshot: pct rollback <vmid> <snapname>
  • Delete a snapshot: pct delsnapshot <vmid> <snapname>

Container Backup and Restore

  • Backup a container: vzdump <vmid> --mode snapshot --compress gzip --storage <storage>
  • Restore a container: pct restore <vmid> <backup-file>

Container Monitoring

  • Show container status: pct status <vmid>
  • Show container resource usage: pct top <vmid>
  • Show container logs: pct log <vmid>

Common Options

  • --unprivileged 1: Run the container as an unprivileged user.
  • --arch <arch>: Set the container architecture (e.g., amd64, i386).
  • --ostype <type>: Set the OS type (e.g., debian, ubuntu, unmanaged).
  • --hostname <name>: Set the container hostname.
  • --storage <storage>: Set the storage for the container.
  • --net<N>: Configure network devices for the container.
  • --cpu <cpu>: Set the CPU type for the container.
  • --memory <size>: Set the memory size for the container.
  • --swap <size>: Set the swap size for the container.
  • --rootfs <volume>: Set the root filesystem for the container.

This cheatsheet covers the essential commands and options for creating and managing LXC containers in Proxmox using the pct command. It includes examples of container creation, management, configuration, snapshots, backup/restore, and monitoring.

Remember to replace <vmid>, <ostemplate>, and other placeholders with actual values when using the commands. Adjust the options and parameters according to your specific requirements and environment.