OptionalconfigPath: stringOptionalalt_file: stringFull path to the container's configuration directory.
Each container can have a custom configuration path; by default it is the lxc.lxcpath
global config value (typically /var/lib/lxc).
Whether the container wishes to be daemonized (detached from the controlling terminal) on start.
Last error number and human-readable description of the last error that occurred.
Determine the current state of the container.
One of the ContainerState string values.
Add a host device node into a running container.
{string} Full path of the device on the host (e.g. "/dev/sdb").
Optionaldest_path: string{string | undefined} Path inside the container. Defaults to src_path.
Resolves on success; rejects on error.
Open a shell inside the container and wait for it to exit.
Uses lxc_attach_run_shell internally, which spawns /bin/sh (or the container's default shell).
The shell inherits the attach options (namespaces, environment, uid/gid, etc.).
Optionaloptions: Partial<lxc_attach_options>{Partial<lxc_attach_options>} Attach options. Uses LXC defaults if omitted.
Exit code of the shell process.
Move a host network interface into a running container.
{string} Name of the network device on the host (e.g. "eth1").
Optionaldst_dev: string{string | undefined} Name to use inside the container. Defaults to dev.
Resolves on success; rejects on error.
Checkpoint a running container using CRIU. The container state is written to directory
and the container can optionally be stopped afterwards.
{string} Directory path to write the checkpoint images to.
Optionalstop: boolean{boolean} Stop the container after checkpointing. Default false.
Optionalverbose: boolean{boolean} Enable verbose CRIU logging. Default false.
Resolves on success; rejects on error.
Clear a single key from the container's in-memory configuration.
{string} Name of the configuration key to remove (e.g. "lxc.net.0.type").
Clone (copy) a stopped container into a new container. The source container must be stopped.
{lxc_clone_options} Clone parameters including new name, backing store, and flags.
Resolves with a Container instance for the new clone.
Allocate and run a console TTY, blocking until the user exits.
This connects the calling process's stdio to the container console.
Use consoleAsync instead for non-blocking programmatic access.
{number} TTY number to allocate (-1 = first available, 0 = console).
{[number, number, number]} File descriptors [stdinfd, stdoutfd, stderrfd] to use.
{number} Escape character as integer (1 = Ctrl+a, 2 = Ctrl+b, …).
Resolves when the user exits the console.
Allocate a console TTY and return an async event-emitting session object.
The returned ConsoleSession emits data events with Buffer chunks and a close event
when the session ends. Supports write(data), resize(cols, rows), and close().
This is a custom enhancement not directly in the LXC C API.
Optionalttynum: number{number} TTY number to allocate, or -1 for the first available. Default -1.
Active console session.
Allocate a console TTY file descriptor pair for the container without attaching to it.
The returned ttyfd keeps the TTY allocated; close both descriptors when done.
Optionalttynum: number{number} TTY number to allocate, or -1 for the first available. Default -1.
Tuple of [ttyfd, ptxfd] — the TTY and pseudoterminal master fds.
Query or clear the container's in-kernel console ring buffer log.
Optionaloptions: Partial<lxc_console_log>{Partial<lxc_console_log>} Options controlling whether to read, clear, and how many bytes to return.
The console log data as a string.
Create a new container using a template or a pre-built image.
This runs the template script (e.g. download, ubuntu) to populate the rootfs.
Optionalargv?: string[]{string[]} Arguments to pass to the template script (e.g. distro/release/arch).
Optionalbdev_specs?: Partial<bdev_specs>{Partial<bdev_specs>} Backing store parameters (LVM VG, ZFS root, etc.).
Optionalbdevtype?: string{string} Backing store type ("dir", "lvm", "zfs", "rbd", etc.). Default "dir".
Optionalflags?: LXC_CREATE{LXC_CREATE} Creation flags (e.g. LXC_CREATE.QUIET).
Optionaltemplate?: string{string} Template name to use (e.g. "download", "ubuntu"). Default "none".
Resolves when the container has been created; rejects on error.
Delete the container and optionally its snapshots.
The container must be stopped before calling this unless force is set.
Internally calls destroy_with_snapshots when include_snapshots is true.
Optionaloptions: { force?: boolean; include_snapshots?: boolean }Optionalforce?: boolean{boolean} Stop the container first if it is running. Default false.
Optionalinclude_snapshots?: boolean{boolean} Destroy all snapshots too. Default false.
Resolves on success; rejects if destruction fails.
Remove a network interface from a running container and return it to the host.
{string} Name of the network device inside the container.
Optionaldst_dev: string{string | undefined} Name to restore on the host. Defaults to dev.
Resolves on success; rejects on error.
Run a command inside the container and wait for it to exit.
Uses lxc_attach_run_command internally. argv[0] is the program to run;
subsequent entries are its arguments.
{Partial<lxc_attach_options>} Additional attach options (uid, gid, env, namespaces, etc.).
{string[]} Command and arguments (e.g. ["/bin/ls", "-la", "/tmp"]).
{string[]} Command and arguments (e.g. ["/bin/ls", "-la", "/tmp"]).
Exit code of the command that ran inside the container.
Run a command inside the container and stream its output as events.
Resolves with a session object once the process has started.
Register all listeners before the first await after this call so
no output is lost between process start and listener registration.
{Partial<lxc_attach_options>} Attach options. stdio is ignored.
{string[]} Command and arguments.
{string[]} Command and arguments.
Active streaming session.
Run a command inside the container and capture its output. Internally creates pipes for stdout and stderr so the child never writes to the caller's terminal. Both streams are collected in memory and returned when the process exits.
{Partial<lxc_attach_options>} Attach options (uid, gid, env, …). stdio is ignored.
{string[]} Command and arguments.
{string[]} Command and arguments.
{ exitCode, stdout, stderr }.
Retrieve the value of a cgroup subsystem entry for the container.
Returns undefined if the subsystem does not exist or is not available.
{string} cgroup subsystem path (e.g. "memory.usage_in_bytes", "cpu.stat").
The cgroup value string, or undefined.
Retrieve the value of a configuration key from the container's in-memory config.
Returns null if the key does not exist or has no value.
{string} Configuration key to retrieve (e.g. "lxc.net.0.type").
The value string, or null if absent.
Retrieve all configuration keys and their values in a single call.
More efficient than calling getKeys(prefix) followed by N getConfigItem(key) calls.
Optionalprefix: string{string | undefined} Optional key prefix to filter by (e.g. "lxc.net").
Pass undefined to retrieve all keys.
Object mapping each key to its value, or null if
the key exists but has no value.
Retrieve all network interfaces currently visible inside the container. The container must be running.
Array of interface name strings (e.g. ["lo", "eth0"]).
Retrieve IPv4 addresses assigned to a container interface. The container must be running.
{string} Network interface name (e.g. "eth0").
{"inet"} Address family — use "inet" for IPv4.
Array of IPv4 address strings in dotted-decimal notation.
Retrieve IPv6 addresses assigned to a container interface. The container must be running.
{string} Network interface name (e.g. "eth0").
{"inet6"} Address family — use "inet6" for IPv6.
{number} IPv6 scope ID to filter by (e.g. 0 for global).
Array of IPv6 address strings.
Retrieve all configuration keys that match the given prefix.
Use this to enumerate available keys, then call getConfigItem on each.
For bulk reads, prefer getConfigItems which fetches keys and values in one call.
Optionalprefix: string{string} Key prefix to filter by (e.g. "lxc.net"). Pass undefined for all keys.
Array of matching key strings.
Retrieve the value of a configuration key from a running container's live state.
Unlike getConfigItem, this reads values that may differ from the on-disk config
(e.g. effective network settings, runtime cgroup values).
Returns null if the key does not exist or the container is not running.
{string} Configuration key to retrieve.
The live value string, or null if absent.
Perform a migration operation (dump, restore, or pre-dump) using CRIU.
Use the LXC_MIGRATE enum values for cmd.
{LXC_MIGRATE} Operation to perform (MIGRATE_DUMP, MIGRATE_RESTORE, or MIGRATE_PRE_DUMP).
Optionaloptions: Partial<migrate_opts>{Partial<migrate_opts>} Migration options including directory, page server address, etc.
Resolves on success; rejects on error.
Bind-mount a host path into the running container.
Equivalent to calling mount(2) inside the container's mount namespace.
{string} Host filesystem path to mount.
{string} Mount point inside the container.
{string | undefined} Filesystem type (e.g. "tmpfs"), or undefined for bind mounts.
{bigint | number | LXC_MOUNT} Flags passed to mount(2) (e.g. MS_BIND, MS_RDONLY).
{lxc_mount} Mount API version descriptor. Set version to 0.
Resolves on success; rejects on error.
Request the container to reboot by sending it SIGINT to its init process.
Waits up to timeout seconds for the reboot to complete.
Internally uses reboot2 which supports a timeout parameter.
Optionaltimeout: number{number} Seconds to wait; -1 waits forever, 0 does not wait. Default -1.
Resolves with true if the reboot completed within the timeout.
Remove a device node from a running container.
{string} Full path of the device on the host.
Optionaldest_path: string{string | undefined} Path inside the container. Defaults to src_path.
Resolves on success; rejects on error.
Retrieve a file descriptor for the container's seccomp notification filter.
Used to receive seccomp notifications from the container via poll(2).
The container does not need to be running; the fd is pre-loaded at container start.
The seccomp notification fd.
Retrieve a file descriptor for the running container's active seccomp filter.
Unlike seccompNotifyFd, this reflects the live filter of a running container.
The active seccomp notification fd.
Set a cgroup subsystem value for the container. The container must be running for most cgroup writes to take effect.
{string} cgroup subsystem path (e.g. "memory.limit_in_bytes").
{string} Value to write (e.g. "536870912" for 512 MiB).
Set a single key/value pair in the container's in-memory configuration.
Call save() afterwards to persist the change to disk.
{string} Configuration key (e.g. "lxc.log.file").
{string} Value to set.
Request the container to shut down gracefully by sending SIGPWR to its init process.
Waits up to timeout seconds for the shutdown to complete.
Optionaltimeout: number{number} Seconds to wait; -1 waits forever, 0 does not wait. Default -1.
Resolves with true if shutdown completed within the timeout.
Create a container snapshot at the current state.
Snapshots are stored as snap<N> under the container's snapshot directory
(typically /var/lib/lxc/<name>/snaps/snap<N>).
{string} Full path to a file containing a human-readable description of the snapshot.
The zero-based snapshot number assigned (e.g. 0 for snap0).
Destroy a single named snapshot.
{string} Name of the snapshot to destroy (e.g. "snap0").
Destroy all snapshots for this container.
{true} Must be true.
List all snapshots for this container.
Array of snapshot descriptor objects.
Restore a container from a named snapshot.
The restored container is a full copy of the snapshot placed at newname in the same lxcpath.
{string} Snapshot name (e.g. "snap0").
Optionalnewname: string{string} Name for the restored container. Defaults to the current container's name, which replaces the container in-place (fails for overlay-based snapshots that pin the original).
Resolves when the restore is complete.
Start the container. If the container is already running, this is a no-op.
Optionaluseinit: number{number} Pass 1 to use lxcinit rather than /sbin/init. Default 0.
Optionalargv: string[]{string[]} Optional arguments to pass to the init process.
Resolves when the container has started; rejects on error.
Retrieve a snapshot of common resource usage metrics for a running container.
Reads six cgroup v1 entries in a single async operation. Returns null for
any metric not available on the host kernel or cgroup hierarchy.
Object with cgroup metric values.
Unmount a path inside the running container.
{string} Path inside the container to unmount.
{bigint | number} Flags passed to umount2(2) (e.g. MNT_DETACH).
{lxc_mount} Mount API version descriptor. Set version to 0.
Resolves on success; rejects on error.
Block until the container reaches the specified state or the timeout expires.
{ContainerState} The target state to wait for.
Optionaltimeout: number{number} Seconds to wait; -1 waits forever, 0 returns immediately. Default -1.
Resolves when the state is reached; rejects on timeout or error.
Set whether all file descriptors should be closed before the container's init process starts.
{boolean} true to close all fds on startup.
true on success.
Current configuration file name (full path).