LinuxCommandLibrary

lxc-info

Get information about an LXC container

TLDR

Query information from a container

$ sudo lxc-info [container_name]
copy

Display help
$ lxc-info [[-?|--help]]
copy

SYNOPSIS

lxc-info -n name [-i] [-s] [-p] [-H] [--version] [-L] [-f config]

PARAMETERS

-n name
    Specifies the name of the container to query. This option is mandatory.

-i
    Displays the IP address(es) assigned to the container.

-s
    Shows the current state of the container (e.g., RUNNING, STOPPED, FROZEN).

-p
    Outputs the Process ID (PID) of the container's main process.

-H
    Suppresses the header line from the output, useful for scripting or parsing.

--version
    Prints the version information of the lxc-info command.

-L
    Displays the full path to the container's log file.

-f config
    Specifies an alternate configuration file for the container instead of the default location.

DESCRIPTION

lxc-info is a command-line utility within the Linux Containers (LXC) framework. Its primary purpose is to retrieve and display specific information about a designated LXC container. By default, when executed with only a container name, it provides the container's current state (e.g., RUNNING, STOPPED), its main process ID (PID), and its assigned IP address(es). Users can refine the output using various options: for instance, -s will only show the state, -p the PID, and -i the IP addresses. This command is essential for quickly checking the operational status and network connectivity of LXC containers, aiding in monitoring and troubleshooting tasks. It acts as a quick diagnostic tool for administrators managing containerized environments.

CAVEATS

Requires root privileges or appropriate CAP_SYS_ADMIN capabilities to access container information.
The IP address reported is typically the one assigned to the container's main network interface. Multiple IPs might be shown if multiple interfaces are configured.
The command relies on the LXC system being properly configured and the container definition files being accessible.

DEFAULT OUTPUT

If no specific display options (-i, -s, -p) are provided, lxc-info defaults to displaying the container's state, PID, and IP addresses. This provides a quick overview of the container's status without needing to specify multiple flags.

HISTORY

LXC (Linux Containers) has been under active development since 2008, providing a lightweight virtualization solution prior to the widespread adoption of other container runtimes. lxc-info has been a fundamental utility within the LXC toolset from its early stages, serving as a basic but crucial command for querying the operational status of containers. Its functionality has remained largely consistent, reflecting its core role in container management. As LXC evolved, lxc-info continued to be an essential part of the suite, supporting quick diagnostics for container lifecycle management.

SEE ALSO

Copied to clipboard