mirror of
https://github.com/containers/podman.git
synced 2025-06-29 06:57:13 +08:00
Merge pull request #15136 from Luap99/systemd-generate-hostname
podman generate systemd --new: allow -h hostname
This commit is contained in:
@ -378,6 +378,9 @@ func executeContainerTemplate(info *containerInfo, options entities.GenerateSyst
|
|||||||
fs.StringArrayP("env", "e", nil, "")
|
fs.StringArrayP("env", "e", nil, "")
|
||||||
fs.String("sdnotify", "", "")
|
fs.String("sdnotify", "", "")
|
||||||
fs.String("restart", "", "")
|
fs.String("restart", "", "")
|
||||||
|
// have to define extra -h flag to prevent help error when parsing -h hostname
|
||||||
|
// https://github.com/containers/podman/issues/15124
|
||||||
|
fs.StringP("help", "h", "", "")
|
||||||
if err := fs.Parse(remainingCmd); err != nil {
|
if err := fs.Parse(remainingCmd); err != nil {
|
||||||
return "", fmt.Errorf("parsing remaining command-line arguments: %w", err)
|
return "", fmt.Errorf("parsing remaining command-line arguments: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -811,6 +811,37 @@ ExecStopPost=/usr/bin/podman rm -f --ignore --cidfile=%t/%n.ctr-id
|
|||||||
Type=notify
|
Type=notify
|
||||||
NotifyAccess=all
|
NotifyAccess=all
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
||||||
|
`
|
||||||
|
|
||||||
|
goodNewWithHostname := `# jadda-jadda.service
|
||||||
|
# autogenerated by Podman CI
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=Podman jadda-jadda.service
|
||||||
|
Documentation=man:podman-generate-systemd(1)
|
||||||
|
Wants=network-online.target
|
||||||
|
After=network-online.target
|
||||||
|
RequiresMountsFor=/var/run/containers/storage
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Environment=PODMAN_SYSTEMD_UNIT=%n
|
||||||
|
Restart=on-failure
|
||||||
|
TimeoutStopSec=70
|
||||||
|
ExecStartPre=/bin/rm -f %t/%n.ctr-id
|
||||||
|
ExecStart=/usr/bin/podman run \
|
||||||
|
--cidfile=%t/%n.ctr-id \
|
||||||
|
--cgroups=no-conmon \
|
||||||
|
--rm \
|
||||||
|
--sdnotify=conmon \
|
||||||
|
-d \
|
||||||
|
-h hostname awesome-image:latest
|
||||||
|
ExecStop=/usr/bin/podman stop --ignore --cidfile=%t/%n.ctr-id
|
||||||
|
ExecStopPost=/usr/bin/podman rm -f --ignore --cidfile=%t/%n.ctr-id
|
||||||
|
Type=notify
|
||||||
|
NotifyAccess=all
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=default.target
|
WantedBy=default.target
|
||||||
`
|
`
|
||||||
@ -1432,6 +1463,25 @@ WantedBy=default.target
|
|||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
|
{"good with -h hostname",
|
||||||
|
containerInfo{
|
||||||
|
Executable: "/usr/bin/podman",
|
||||||
|
ServiceName: "jadda-jadda",
|
||||||
|
ContainerNameOrID: "jadda-jadda",
|
||||||
|
PIDFile: "/var/run/containers/storage/overlay-containers/639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401/userdata/conmon.pid",
|
||||||
|
StopTimeout: 10,
|
||||||
|
PodmanVersion: "CI",
|
||||||
|
GraphRoot: "/var/lib/containers/storage",
|
||||||
|
RunRoot: "/var/run/containers/storage",
|
||||||
|
CreateCommand: []string{"I'll get stripped", "create", "-h", "hostname", "awesome-image:latest"},
|
||||||
|
EnvVariable: define.EnvVariable,
|
||||||
|
},
|
||||||
|
goodNewWithHostname,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
},
|
||||||
{"good template",
|
{"good template",
|
||||||
containerInfo{
|
containerInfo{
|
||||||
Executable: "/usr/bin/podman",
|
Executable: "/usr/bin/podman",
|
||||||
|
Reference in New Issue
Block a user