178 Commits

Author SHA1 Message Date
08a1c6d91e Add support for Retry= and RetryDelay= to Podman Quadlet.
This commit adds new Retry= and RetryDelay= options
to quadlet.go which result in --retry and --retry-delay
usage in podman run, image and build commands.

This allows configuring the retry logic in the systemd
files.

Fixes: #25109

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
2025-03-26 09:01:28 +01:00
10290d462b docs: Improve spelling and formatting
Signed-off-by: Alexander Gramiak <agrambot@gmail.com>
2025-03-24 16:35:29 -06:00
543be25ef3 quadlet: support Memory= in [Container] sections
Maps to the `--memory=` flag.

Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
2025-02-17 17:29:15 +01:00
e93f0acbee docs: Add quadlet debug method systemd-analyze
Reference: https://github.com/containers/podman/discussions/24891

Signed-off-by: Erik Sjölund <erik.sjolund@gmail.com>
2025-01-16 08:27:47 +01:00
418ea52e06 Document .build for Image .container option
$NAME.build is supported in .container to automatically build the
local image. This needs to be documented.

Also fix up other special cases to look the same in the man page.

Fixes: https://www.reddit.com/r/podman/comments/1hmhhhi/quadlet_build_units/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2025-01-07 14:20:43 -05:00
d1a3f96cbf Add support to ShmSize in Pods with Quadlet
This closes #22915

Signed-off-by: Odilon Sousa <osousa@redhat.com>
2024-12-30 12:33:00 -03:00
6809bf1d90 doc: fix words repetitions
Signed-off-by: Maël Azimi <mael.azimi@moul.re>
2024-11-13 15:21:40 +01:00
a358d83ce9 Merge pull request #24437 from lambinoo/feat-split-pod-container-start-24401
Add key to control if a container can get started by its pod
2024-11-05 15:04:16 +00:00
2597eeae70 Add key to control if a container can get started by its pod
By default today, the container is always started if its pod is also
started. This prevents to create custom with systemd where containers in
a pod could be started through their `[Install]` section.

We add a key `StartWithPod=`, enabled by default, that enables one to
disable that behavior.

This prevents the pod service from changing the state of the container
service.

Fixes #24401

Signed-off-by: Farya L. Maerten <me@ltow.me>
2024-11-05 08:39:23 +01:00
dbfc8cccda Quadlet - support image file based mount in container file
Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2024-11-01 16:20:23 -04:00
67e0fa8b89 quadlet: add default network dependencies to all units
There is no good reason for the special case, kube and pod units
definitely need it. Volume and network units maybe not but for
consistency we add it there as well. This makes the docs much easier to
write and understand for users as the behavior will not differ.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-10-18 14:01:22 +02:00
57b022782b quadlet: ensure user units wait for the network
As documented in the issue there is no way to wait for system units from
the user session[1]. This causes problems for rootless quadlet units as
they might be started before the network is fully up. TWhile this was
always the case and thus was never really noticed the main thing that
trigger a bunch of errors was the switch to pasta.

Pasta requires the network to be fully up in order to correctly select
the right "template" interface based on the routes. If it cannot find a
suitable interface it just fails and we cannot start the container
understandingly leading to a lot of frustration from users.

As there is no sign of any movement on the systemd issue we work around
here by using our own user unit that check if the system session
network-online.target it ready.

Now for testing it is a bit complicated. While we do now correctly test
the root and rootless generator since commit ada75c0bb8 the resulting
Wants/After= lines differ between them and there is no logic in the
testfiles themself to say if root/rootless to match specifics. One idea
was to use `assert-key-is-rootless/root` but that seemed like more
duplication for little reason so use a regex and allow both to make it
pass always. To still have some test coverage add a check in the system
test to ask systemd if we did indeed have the right depdendencies where
we can check for exact root/rootless name match.

[1] https://github.com/systemd/systemd/issues/3312

Fixes #22197

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-10-18 11:43:48 +02:00
bac655a6b1 Allow removing implicit quadlet systemd dependencies
Quadlet inserts network-online.target Wants/After dependencies to ensure pulling works.
Those systemd statements cannot be subsequently reset.

In the cases where those dependencies are not wanted, we add a new
configuration item called `DefaultDependencies=` in a new section called
[Quadlet]. This section is shared between different unit types.

fixes #24193

Signed-off-by: Farya L. Maerten <me@ltow.me>
2024-10-09 14:48:05 +02:00
95a55f971c Merge pull request #24177 from eriksjolund/docs-prefer-option-network
docs: prefer --network to --net
2024-10-07 09:18:50 +00:00
d0cb62aacc podman-systemd.unit.5: adjust example options
Use the reserved domain name example.com in the examples.
For details, see RFC 2606
https://datatracker.ietf.org/doc/html/rfc2606#section-3

Modify PublishPort examples to make them reflect more
common scenarios.

Fixes: https://github.com/containers/podman/issues/23954

Signed-off-by: Erik Sjölund <erik.sjolund@gmail.com>
2024-10-06 17:31:41 +02:00
374844817d docs: prefer --network to --net
The option --network is the more official option as it is
listed in

podman run --help
podman kube play --help

Signed-off-by: Erik Sjölund <erik.sjolund@gmail.com>
2024-10-05 09:10:15 +02:00
4e38381d37 Merge pull request #23900 from Honny1/healthcheck-log
HealthCheck log output options
2024-09-26 11:55:55 +00:00
de856dab99 Add --health-max-log-count, --health-max-log-size, --health-log-destination flags
These flags can affect the output of the HealtCheck log. Currently, when a container is configured with HealthCheck, the output from the HealthCheck command is only logged to the container status file, which is accessible via `podman inspect`.
It is also limited to the last five executions and the first 500 characters per execution.

This makes debugging past problems very difficult, since the only information available about the failure of the HealthCheck command is the generic `healthcheck service failed` record.

- The `--health-log-destination` flag sets the destination of the HealthCheck log.
  - `none`: (default behavior) `HealthCheckResults` are stored in overlay containers. (For example: `$runroot/healthcheck.log`)
  - `directory`: creates a log file named `<container-ID>-healthcheck.log` with JSON `HealthCheckResults` in the specified directory.
  - `events_logger`: The log will be written with logging mechanism set by events_loggeri. It also saves the log to a default directory, for performance on a system with a large number of logs.

- The `--health-max-log-count` flag sets the maximum number of attempts in the HealthCheck log file.
  - A value of `0` indicates an infinite number of attempts in the log file.
  - The default value is `5` attempts in the log file.
- The `--health-max-log-size` flag sets the maximum length of the log stored.
  - A value of `0` indicates an infinite log length.
  - The default value is `500` log characters.

Add --health-max-log-count flag

Signed-off-by: Jan Rodák <hony.com@seznam.cz>

Add --health-max-log-size flag

Signed-off-by: Jan Rodák <hony.com@seznam.cz>

Add --health-log-destination flag

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2024-09-25 14:01:35 +02:00
133ea31ffb Quadlet - add full support for Symlinks
Use os.ReadDir recursively instead of filepath.WalkDir
Use map instead of list to easily find looped Symlinks
Update existing tests and add a more elaborate one
Update the man page

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2024-09-20 11:11:03 -04:00
15bde1abdb Add DNS, DNSOption and DNSSearch to quadlet pod
Signed-off-by: Steve Jibson <steve@jibson.com>
2024-09-04 11:31:32 -06:00
71fd15726d quadlet: support container network reusing
Signed-off-by: Misaki Kasumi <misakikasumi@outlook.com>
2024-08-30 21:35:21 +08:00
2b14db2af3 Quadlet - Support multiple image tags in .build files
Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2024-08-29 15:07:49 -04:00
7c5d8bec0d Add support for AddHost in quadlet .pod and .container
Signed-off-by: Jerome degroote <jeromedu59230@gmx.fr>
2024-08-26 14:32:08 +02:00
d55b12f70b Add support for IP in quadlet .pod files
Signed-off-by: Jerome degroote <jeromedu59230@gmx.fr>
2024-08-22 14:51:12 +02:00
e7905122d7 Merge pull request #23679 from ruihe774/pod-userns
quadlet: support user mapping in pod unit
2024-08-22 12:33:43 +00:00
4fbfa7de6e quadlet: support user mapping in pod unit
Signed-off-by: Misaki Kasumi <misakikasumi@outlook.com>
2024-08-22 09:41:06 +08:00
1ccccde183 quadlet: add key CgroupsMode
Signed-off-by: Misaki Kasumi <misakikasumi@outlook.com>
2024-08-20 22:09:36 +08:00
d26341332c docs/podman-systemd: Try to clarify Exec= more
In podman-systemd we are intersecting the worlds of containers
and systemd, and I had to stop and think to understand what
`Exec=` does.

I tried to clarify things more here.

I found it especially confusing because the example at the
very top of the file does:

```
Image=quay.io/fedora/fedora
Exec=sleep 10
```

But that only makes sense because the fedora base image
(being generic) doesn't define an `ENTRYPOINT`, just a `CMD`.

But IMO by far the most common usage for podman-systemd
is "app images" which conventionally should use `ENTRYPOINT`
in general. Maybe we should change the default example,
but I'm leaving that for a later followup.

(It perhaps would have been less confusing if this field
 had been called `Args=` to make clear it's quite different
 in practice from systemd `ExecStart=`)

Signed-off-by: Colin Walters <walters@verbum.org>
2024-08-12 09:03:57 -04:00
f3a86266e6 Quadlet - Allow the user to set the service name for .pod files
Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2024-07-29 16:11:19 +03:00
ce7dded38b Add /run/containers/systemd, ${XDG_RUNTIME_DIR}/containers/systemd quadlet dirs
Fixes: https://github.com/containers/podman/issues/23363

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-07-24 09:28:00 -04:00
7768cf235e Run codespell on source
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-07-23 07:28:23 -04:00
0ecd6fa59f Add support for StopSignal in quadlet .container files
Fixes: https://github.com/containers/podman/issues/23050

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-07-22 06:43:45 -04:00
3c52ef43f5 Expand drop-in search paths
* top-level (pod.d)
* truncated (unit-.container.d)

Signed-off-by: Bennie Milburn-Town <63211101+benniekiss@users.noreply.github.com>
2024-07-17 17:43:02 -04:00
54fce37968 Add NetworkAlias= support to quadlet
Adds a `NetworkAlias=` key to both .container and .pod quadlet files,
which translates to the `--network-alias` option to `podman run` and
`podman pod create` respectively. Can be repeated multiple times.

Signed-off-by: Félix Saparelli <felix@passcod.name>
2024-07-15 16:39:25 +12:00
22b57d3230 feat(quadlet): log option handling
I found that Quadlet didn't currently have support for log options.
This merge allows Quadlet to handle log options and correctly
pass those values through to `podman run` for Container and Kube
types.

Syntactically consistent with existing parameters:

```ini
[Container]
Image=localhost/imagename
LogOpt=path=/var/log/container/mycontainer.json
LogOpt=size=10mb
```

Signed-off-by: Brett Calliss <brett@obligatory.email>
2024-06-30 18:21:47 +10:00
1128e5b410 Merge pull request #23072 from marinmo/update-systemd-unit.md
[CI:DOCS] Add information about Type=oneshot units in podman-systemd.unit.5.md (fixes #22233)
2024-06-24 12:27:59 +00:00
945226a844 fix #22233
Add information about Type=oneshot units as suggested in https://github.com/containers/podman/issues/22233

Signed-off-by: marinmo <bugzilla@marinmo.org>
2024-06-23 19:11:51 +02:00
e4f64f91fe fix #20686
Change the document to only use true/false for booleans. Fixes https://github.com/containers/podman/issues/20686.

Signed-off-by: marinmo <bugzilla@marinmo.org>
2024-06-22 22:17:24 +02:00
dca94be028 [CI:DOCS] Quadlet - add note about relative path resolution
Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2024-06-17 17:32:34 +03:00
9f823ecb25 Quadlet: Add support for .build files
.build files allow to build an image via Quadlet. The keys from a .build
file are translated to arguments of a `podman build` command by Quadlet.

Minimal keys for .build files are `ImageTag=` and a context directory,
see `SetWorkingDirectory=`, or a `File=` pointing to a Containerfile.

After sorting .build files into the Quadlet dependency order, there
remains a possible dependency cycle issue between .volume and .build
files: A .volume can have `Image=some.build`, and a .build can have
`Volume=some.volume:/some/volume`.

We solve this dependency cycle by prefilling resourceNames with all
image names from .build files before converting all the unit files.

This results in an issue for the test suite though: For .volume's
depending on *.image or *.build, we need to copy these additional
dependencies to the test's quadletDir, otherwise the test will fail.
This is necessary, because `handleImageSource()` actually needs to know
the image name defined in the referenced *.{build,image} file. It cannot
fall back on the default names, as it is done for networks or volumes,
for example.

Signed-off-by: Johannes Maibaum <jmaibaum@gmail.com>
2024-05-27 16:59:39 +02:00
ad1d3f8fc7 quadlet: Add a network requirement on .image units
If a container unit starts on boot with a dependency on `default.target`
the image unit may start too soon, before network is ready. This cause
the unit to fail to pull the image.
- Add a dependency on `network-online.target` to make sure image pulls
don't fail.
See https://github.com/containers/podman/issues/21873

- Document the hardcoded dependency on `network-online.target` for images unit
and explain how it can be overriden if necessary.

- tests/e2e/quadlet: Add `assert-last-key-regex`

Required to test the `After=` override in [Unit] section
See https://github.com/containers/podman/pull/22057#issuecomment-2008959993

- quadlet/unitfile: add a prepenUnitLine method

Requirements on networks should be inserted at the top of the
section so the user can override them.

Signed-off-by: jbtrystram <jbtrystram@redhat.com>
2024-05-22 13:46:42 +02:00
6d1098f823 Quadlet/Container: Add GroupAdd option
Co-authored-by: Ygal Blum <ygal.blum@gmail.com>
Signed-off-by: Jonas Berlin <xkr47@outerspace.dyndns.org>
2024-05-08 16:00:28 +03:00
36e4d512b3 docs: update Quadlet volume Options desc
Signed-off-by: localhost <xpaomian@gmail.com>
2024-04-09 11:37:20 +08:00
d2143fac59 s3fs docs
Signed-off-by: WesselAtWork <115667066+WesselAtWork@users.noreply.github.com>
2024-04-03 10:18:49 +00:00
d3927f9076 Add note about host networking to Kube PublishPort option
Signed-off-by: Eric D. Helms <ericdhelms@gmail.com>
2024-04-02 10:44:45 -04:00
3d6758a61d docs: quadlet: improve docs on root/rootless dirs
Make the docs more explicit on which directories are read for root and
rootless users to avoid confusion [1].

[1] https://github.com/containers/podman/discussions/20218#discussioncomment-8721351

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2024-03-11 09:00:43 +01:00
10265661ec Fix Quadlet Options=key=value documentation/example
Quadlet `[Network]` does not accept `Options=key` for `podman network create --opt key`. Options have to be provided in `key=value` format, where the `=` is required even though the value may be empty.

One usage example is `Options=isolate=true`. In this case, passing `netavark` an empty `isolate` value may be a valid/parseable setting: `Options=isolate=`, equivalent to `Options=isolate=false`.

This commit documents the explicit `Options=key=value` usage. Compare to `[Network]` tests, which use `key=value`.

Usage verified locally by inspecting the generated network in `/run/user/${UID}/systemd/generator/example-network.service` and `podman network inspect systemd-example` using podman v4.9.2 and netavark v1.10.2.

See

- https://docs.podman.io/en/latest/markdown/podman-systemd.unit.5.html#network-units-network
- https://github.com/containers/podman/blob/v4.9.2/test/e2e/quadlet/options.network
- https://github.com/containers/podman/blob/v4.9.2/test/e2e/quadlet/options.multiple.network
- https://github.com/containers/netavark/blob/v1.10.2/src/network/bridge.rs#L824-L833

Signed-off-by: Joel Purra <mig@joelpurra.se>
2024-02-08 17:48:36 +01:00
dc94a10d68 quadlet: Add documentation about template use to manpage
Signed-off-by: Alexander Larsson <alexl@redhat.com>
2024-01-26 13:57:47 +01:00
a5612bc540 Quadlet: ensure all keys are documented
New CI validation check: all keys in quadlet.go must be
documented at least once in podman-systemd.unit.5.md.
Adding '// deprecated' next to an enum definition will
exclude said key from the documentation cross-checks.

And, because the md file lists keys in both table and block
form, make sure those all match.

And make sure everything is sorted in lexical order, in
both .go source and in man page.

And add a validation check to make sure it stays that way.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-01-18 06:17:57 -07:00
3714ae3420 quadlet: fix quoting of example option values in container unit file documentation
The quotes are interpreted as part of the value, so that, for example,
`HealthCmd="true"` is translated to the podman argument
`--health-cmd "\"true\""`.

Signed-off-by: Cedric Staniewski <cedric@gmx.ca>
2024-01-11 00:02:41 +01:00