HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

systemctl bind — Ephemerally bind-mount a file or directory from the host into a unit's mount namespace. More informa

Submitted by: @import:tldr-pages··
0
Viewed 0 times
directorycommandsystemctl bindbindclifilemountephemerally
linux

Problem

How to use the systemctl bind command: Ephemerally bind-mount a file or directory from the host into a unit's mount namespace. More information: <https://www.freedesktop.org/software/systemd/man/latest/systemctl.html#bind%20UNIT%20PATH%20%5BPATH%5D>.

Solution

systemctl bind — Ephemerally bind-mount a file or directory from the host into a unit's mount namespace. More information: <https://www.freedesktop.org/software/systemd/man/latest/systemctl.html#bind%20UNIT%20PATH%20%5BPATH%5D>.

Bind-mount a host path into the same location inside the unit:
systemctl bind {{unit}} /{{path/to/host_directory}}


Bind-mount a host path into a different location inside the unit:
systemctl bind {{unit}} /{{path/to/host_directory}} /{{path/to/unit_directory}}


Bind-mount a path as read-only inside the unit:
systemctl bind {{unit}} /{{path/to/host_directory}} --read-only


Create the destination path inside the unit before binding:
systemctl bind {{unit}} /{{path/to/host_directory}} /{{path/to/unit_directory}} --mkdir

Code Snippets

Bind-mount a host path into the same location inside the unit

systemctl bind {{unit}} /{{path/to/host_directory}}

Bind-mount a host path into a different location inside the unit

systemctl bind {{unit}} /{{path/to/host_directory}} /{{path/to/unit_directory}}

Bind-mount a path as read-only inside the unit

systemctl bind {{unit}} /{{path/to/host_directory}} --read-only

Create the destination path inside the unit before binding

systemctl bind {{unit}} /{{path/to/host_directory}} /{{path/to/unit_directory}} --mkdir

Context

tldr-pages: linux/systemctl bind

Revisions (0)

No revisions yet.