summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pkg/systemd/generate/containers.go4
-rw-r--r--test/system/250-systemd.bats2
2 files changed, 5 insertions, 1 deletions
diff --git a/pkg/systemd/generate/containers.go b/pkg/systemd/generate/containers.go
index c0a49c614..a4b18ec88 100644
--- a/pkg/systemd/generate/containers.go
+++ b/pkg/systemd/generate/containers.go
@@ -394,6 +394,10 @@ func executeContainerTemplate(info *containerInfo, options entities.GenerateSyst
info.IdentifySpecifier = true
runIx := -1
nameIx := -1
+ // Add systemd identify specifier next to the name value
+ // to set a name to the container according to the parameters passed to systemd.
+ // In case no --name set for that container, use ServiceName specified
+ // in the containerInfo struct.
for argIx, arg := range startCommand {
if arg == "run" {
runIx = argIx
diff --git a/test/system/250-systemd.bats b/test/system/250-systemd.bats
index 28e28b30c..1c778a5e3 100644
--- a/test/system/250-systemd.bats
+++ b/test/system/250-systemd.bats
@@ -204,7 +204,7 @@ LISTEN_FDNAMES=listen_fdnames" "LISTEN Environment passed: $context"
@test "podman generate - systemd template" {
cname=$(random_string)
- run_podman run -dt --name $cname $IMAGE top
+ run_podman create --name $cname $IMAGE top
run_podman generate systemd --template -n $cname
echo "$output" > "$TEMPLATE_FILE_PREFIX@.service"