Quadlet docs: add section on referencing other template Quadlets

Signed-off-by: cyqsimon <28627918+cyqsimon@users.noreply.github.com>
This commit is contained in:
cyqsimon
2026-03-06 16:38:31 +08:00
parent b9da144e2d
commit 047e178298

View File

@@ -204,6 +204,37 @@ create a drop-in file like `sleep@10.container.d/10-image.conf`:
Image=quay.io/centos/centos
```
#### Referencing other template Quadlets
It often occurs that you may want to reference another template Quadlet
from your Quadlet. For example, you may want each instance of `foo@.container`
to mount a distinct volume. In this case you can create a template Quadlet
`foo-data@.volume` (the name is arbitrary) and reference it in `foo@.container`:
`foo-data@.volume`:
```
[Volume]
# Optional: automatic naming does work with template Quadlets too.
# This is just to demonstrate the behaviour of systemd specifiers (e.g. %i).
VolumeName=my-name-%i
```
`foo@.container`:
```
[Container]
Volume=foo-data@.volume:/mnt/path
```
Note that we reference the template name `foo-data@.volume` instead of
the instance name `foo-data@%i.volume`. Quadlet will read the template file
and determine the correct volume name (with the systemd specifier) for
the `podman run` command in the generated `.service` file. In this example,
the `ExecStart` generated by Quadlet would look something like this:
```
ExecStart=/usr/bin/podman run ... -v my-name-%i:/mnt/path ...
```
### Relative paths
In order to support Systemd specifiers, Quadlet does not resolve relative paths that start with `%`.