LinuxCommandLibrary

pct

Manage Proxmox containers and VMs

TLDR

List all containers

$ pct list
copy

Start/Stop/Reboot a specific container
$ pct [start|stop|reboot] [100]
copy

Access a specific container's shell
$ pct [[en|enter]] [100]
copy

Create a container from template with 4GB size
$ pct [[cr|create]] [100] [local:vztmpl/distro-name.tar.zst] --rootfs [local-lvm]:4
copy

Resize the container's disk to 20G
$ pct [[resi|resize]] [100] [rootfs|mpX] [20G]
copy

Show the configuration of a container, specifying its ID
$ pct [[conf|config]] [100]
copy

Snapshot a specific container with description
$ pct [[sn|snapshot]] [100] [my-snapshot] --description [My snapshot description]
copy

Destroy a container and remove all related resources
$ pct [[des|destroy]] [100] --purge
copy

SYNOPSIS

pct command vmid [options]
pct command [options] (for global commands like 'list')

PARAMETERS

create vmid template
    Creates a new LXC container from a specified template.

start vmid
    Starts the specified container.

stop vmid
    Stops the specified container gracefully.

restart vmid
    Restarts the specified container.

destroy vmid
    Permanently deletes the specified container and all its associated data.

config vmid
    Displays the current configuration of the specified container.

set vmid options
    Modifies various configuration settings for the specified container, such as CPU, memory, and network.

list
    Lists all containers managed by Proxmox VE, along with their status and other details.

enter vmid
    Provides direct console access (shell) into the specified running container.

backup vmid
    Creates a backup archive of the specified container.

restore vmid backup-file
    Restores a container from a backup archive, optionally assigning a new VMID.

migrate vmid target-node
    Migrates a container from the current node to another node in a Proxmox cluster.

DESCRIPTION

pct is the primary command-line interface for managing LXC (Linux Containers) within the Proxmox Virtual Environment (PVE). It allows administrators to perform a wide range of operations on containers, including creation, deletion, starting, stopping, restarting, migrating, backing up, and restoring. It also enables modification of container configurations, such as network settings, CPU limits, memory allocation, and storage. pct is an essential tool for automating container management tasks and for those who prefer command-line interaction over the Proxmox web interface. It integrates seamlessly with Proxmox's storage and network configurations, providing a robust solution for container orchestration.

CAVEATS

pct is specific to the Proxmox Virtual Environment and cannot be used on a standalone Linux system without PVE. Most operations require root privileges or equivalent permissions. Incorrect usage, particularly with commands like `destroy` or `set`, can lead to data loss, misconfigured containers, or system instability. Users should have a foundational understanding of LXC concepts and Proxmox's storage and networking models for effective and safe management.

CONTAINER TEMPLATES

pct heavily relies on pre-built container templates, which can be downloaded and managed using the `pveam` command-line tool or through the Proxmox web interface. These templates provide a base operating system for new containers, simplifying deployment.

RESOURCE MANAGEMENT

pct allows granular control over container resources such as CPU cores (e.g., `--cores`), memory (e.g., `--memory`), swap space (e.g., `--swap`), and I/O limits (e.g., `--ioproperty`). These settings are crucial for optimizing performance and ensuring fair resource distribution among containers.

NETWORK CONFIGURATION

Networking for LXC containers can be configured directly via pct set commands, supporting various modes like bridged networking, NAT, and VLANs. These configurations integrate seamlessly with the underlying Proxmox host's network setup, providing flexible connectivity options.

HISTORY

The pct command is an integral part of the Proxmox Virtual Environment, a leading open-source server virtualization management solution. Proxmox VE initially utilized OpenVZ for containerization but transitioned to LXC (Linux Containers) in version 4.0 (released 2015) to leverage upstream kernel features and improve container isolation. pct was developed to provide a native, robust command-line interface for managing these LXC containers within the Proxmox ecosystem, complementing the web-based GUI and ensuring seamless integration with Proxmox's clustering, storage, and networking features. Its development closely tracks Proxmox VE's release cycle, with new features and improvements added regularly.

SEE ALSO

qm(1), lxc(1), pveam(1), pve-manager(7)

Copied to clipboard