Home

lxcattach

lxc-attach is a utility in the Linux Containers (LXC) toolset that allows a user to run a command inside a running container. By attaching to the container's namespaces, it provides direct access to the container's process space, filesystem view, and network environment, enabling interactive inspection and maintenance without starting a new container instance. The standard command is lxc-attach, occasionally written as lxcattach in manuals.

Typical usage is lxc-attach -n container-name -- /bin/bash to open an interactive shell inside the container. A

Under the hood, lxc-attach uses the container's namespaces to execute the specified command in the container's

Access to lxc-attach is typically restricted to users with appropriate permissions, commonly root or a user

See also: lxc-console, lxc-start, lxc-stop.

non-interactive
command
can
also
be
supplied
after
the
--
separator,
for
example
lxc-attach
-n
container-name
--
ls
/etc.
If
no
command
is
given,
an
interactive
session
is
started
by
default.
context.
It
can
allocate
a
pseudo-terminal
for
interactive
use
and
respects
the
container's
user
and
mount
namespace
settings,
so
the
command
sees
the
container’s
environment
rather
than
the
host's.
with
the
necessary
capabilities.
Configuration
and
security
policies
may
limit
usage
to
protect
the
host
system
and
other
containers.