LinuxCommandLibrary

lxc-start

Start a Linux container

TLDR

Start the lxc service

$ systemctl start lxc-net
copy

Start a container
$ sudo lxc-start [container_name]
copy

Start a container in the foreground
$ sudo lxc-start [container_name] [[-F|--foreground]]}
copy

Exit out of a foreground container (run this in a separate terminal)
$ sudo lxc-stop [container_name]
copy

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

SYNOPSIS

lxc-start [-d] [-n container_name] [-o logfile] [-l log level] [-F]

PARAMETERS

-d
    Start the container in daemon mode (background).

-n container_name
    Specify the name of the container to start.

-o logfile
    Specify a log file for container output.

-l log level
    Specify the log level (e.g., TRACE, DEBUG, INFO, WARNING, ERROR, FATAL).

-F
    Start the container in foreground.

DESCRIPTION

The lxc-start command is used to initiate the execution of a Linux container (LXC). It performs the necessary steps to bring the container from a stopped state to a running state. This includes setting up the container's namespace isolation (network, process, mount, etc.), configuring its network interfaces, mounting the root filesystem as defined in the container's configuration file, and finally, executing the container's init process (typically /sbin/init or a similar program).

lxc-start relies heavily on the container's configuration file (usually located at /var/lib/lxc//config) to determine how the container should be set up. It reads this file to determine the root filesystem path, networking parameters, resource limits, and other container-specific settings.

After the container has started, it operates as a separate, isolated environment from the host system, providing a lightweight virtualization solution. The command returns once the container's init process has started. Subsequent interaction with the container typically occurs through other LXC tools such as lxc-attach, lxc-console, or lxc-info.

CONTAINER CONFIGURATION

The behavior of lxc-start is heavily influenced by the container's configuration file. Ensure the configuration file is accurate and reflects the desired state of the container before starting it. Incorrect configurations can lead to container startup failures or unexpected behavior.

ROOT PRIVILEGES

Starting a container typically requires root privileges. Make sure you run lxc-start with sufficient permissions.

SEE ALSO

Copied to clipboard