LinuxCommandLibrary

systemctl-bind

Bind-mount paths into unit namespaces

TLDR

Bind-mount path into unit

$ systemctl bind [unit] [/path/to/host]
copy
Bind to different location in unit
$ systemctl bind [unit] [/host/path] [/unit/path]
copy
Bind as read-only
$ systemctl bind [unit] [/path] --read-only
copy
Create destination before binding
$ systemctl bind [unit] [/host/path] [/unit/path] --mkdir
copy

SYNOPSIS

systemctl bind UNIT PATH [PATH]

DESCRIPTION

systemctl bind ephemerally bind-mounts a file or directory from the host into a running unit's mount namespace. This allows injecting files into sandboxed services without modifying their unit configuration.
If only one path is specified, the mount appears at the same location inside the unit. If two paths are given, the source is mounted at the destination inside the unit.

PARAMETERS

--read-only

Mount the path as read-only inside the unit
--mkdir
Create the destination directory if it doesn't exist

CAVEATS

Requires the unit to have a separate mount namespace (PrivateMounts=yes or similar). Binds are ephemeral and don't persist across unit restarts. The unit must be running.

HISTORY

The bind subcommand was added to systemctl for runtime injection of files into isolated services. It complements systemd's sandboxing features like PrivateMounts and ProtectSystem.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community