Closed zoumingzhe closed 1 month ago
The system service unit seems to only rely on RequiresMountsFor=/run/containers/storage
.
If possible, when executing podman generate systemd
, the nfs directory can be automatically added to RequiresMountsFor
. Otherwise, we can add a --requires-mounts
option, just like --requires
.
[root@files ~]# podman generate systemd --help
[DEPRECATED] Generate systemd units
Description:
Generate systemd units for a pod or container.
The generated units can later be controlled via systemctl(1).
DEPRECATED command:
It is recommended to use Quadlets for running containers and pods under systemd.
Please refer to podman-systemd.unit(5) for details.
Usage:
podman generate systemd [options] {CONTAINER|POD}
Examples:
podman generate systemd CTR
podman generate systemd --new --time 10 CTR
podman generate systemd --files --name POD
Options:
--after stringArray Add dependencies order to the generated unit file
--container-prefix string Systemd unit name prefix for containers (default "container")
-e, --env stringArray Set environment variables to the systemd unit files
-f, --files Generate .service files instead of printing to stdout
--format string Print the created units in specified format (json)
-n, --name Use container/pod names instead of IDs
--new Create a new container or pod instead of starting an existing one
--no-header Skip header generation
--pod-prefix string Systemd unit name prefix for pods (default "pod")
--requires stringArray Similar to wants, but declares stronger requirement dependencies
--restart-policy string Systemd restart-policy (default "on-failure")
--restart-sec uint Systemd restart-sec
--separator string Systemd unit name separator between name/id and prefix (default "-")
--start-timeout uint Start timeout override
--stop-timeout uint Stop timeout override (default 10)
--template Make it a template file and use %i and %I specifiers. Working only for containers
--wants stringArray Add (weak) requirement dependencies to the generated unit file
[root@files ~]#
Could you look at using quadlets rather the podman systemd generate, then you can configure the quadlet file the way you want from a systemd point of view.
Could you look at using quadlets rather the podman systemd generate, then you can configure the quadlet file the way you want from a systemd point of view.
I am currently not considering using quadlet.
I don't think it is realistic to expect we can expose all the systemd configuration from the podman CLI. If you need a custom configuration, just edit the file
I don't think it is realistic to expect we can expose all the systemd configuration from the podman CLI. If you need a custom configuration, just edit the file
I think podman generate systemd
needs to provide necessary options instead of directly editing the file.
"podman generate systemd" is a deprecated command. We are not going to add new flags to a command that will likely be dropped in a future release
Issue Description
I deployed my service using podman-compose and mounted an NFS directory (/mnt/data/download) for the container in Centos Stream9 (5.14.0-437.el9.x86_6). And create a systemd service unit using the
podman generate systemd
command.After my deployment is complete, I can access files in the NFS directory within the container, but when the host restarts, the NFS directory (/mnt/data/download) in the container is always empty.
Steps to reproduce the issue
Steps to reproduce the issue
Describe the results you received
The container works normally, but the nfs directory (/mnt/data/download) is empty.
A manual restart is required to restore.
Describe the results you expected
After restarting the host, the container needs to be mounted by NFS and then started (especially when NFS servers are started simultaneously).
podman info output
Podman in a container
No
Privileged Or Rootless
None
Upstream Latest Release
Yes
Additional environment details
Additional information