1podman-generate-systemd(1)()                      podman-generate-systemd(1)()
2
3
4

NAME

6       podman-generate-systemd  -  Generate  systemd  unit  file(s) for a con‐
7       tainer. Not supported for the remote client
8
9

SYNOPSIS

11       podman generate systemd [options] container|pod
12
13

DESCRIPTION

15       podman generate systemd will create a systemd unit  file  that  can  be
16       used to control a container or pod.  By default, the command will print
17       the content of the unit files to stdout.
18
19
20       Note that this command is not supported for the remote client.
21
22

OPTIONS:

24       --files, -f
25
26
27       Generate files instead of printing to stdout.  The generated files  are
28       named  {container,pod}-{ID,name}.service and will be placed in the cur‐
29       rent working directory.
30
31
32       Note: On a system  with  SELinux  enabled,  the  generated  files  will
33       inherit  contexts  from the current working directory. Depending on the
34       SELinux setup, changes to the generated files using restorecon,  chcon,
35       or  semanage  may  be  required to allow systemd to access these files.
36       Alternatively, use the -Z option when running mv or cp.
37
38
39       --name, -n
40
41
42       Use the name of the container for the start, stop, and  description  in
43       the unit file
44
45
46       --new
47
48
49       Create  a  new container via podman-run instead of starting an existing
50       one.  This option relies on container configuration  files,  which  may
51       not  map directly to podman CLI flags; please review the generated out‐
52       put carefully before placing  in  production.   Since  we  use  systemd
53       Type=forking  service,  using  this option will force the container run
54       with the detached param -d
55
56
57       --time, -t=value
58
59
60       Override the default stop timeout for  the  container  with  the  given
61       value.
62
63
64       --restart-policy=policy
65
66
67       Set  the  systemd  restart  policy.  The restart-policy must be one of:
68       "no",   "on-success",   "on-failure",   "on-abnormal",   "on-watchdog",
69       "on-abort", or "always".  The default policy is on-failure.
70
71

Examples

73       Create and print a systemd unit file for a container running nginx with
74       an always restart policy and 1-second timeout to stdout.
75
76
77              $ podman create --name nginx nginx:latest
78              $ podman generate systemd --restart-policy=always -t 1 nginx
79              # container-de1e3223b1b888bc02d0962dd6cb5855eb00734061013ffdd3479d225abacdc6.service
80              # autogenerated by Podman 1.8.0
81              # Wed Mar 09 09:46:45 CEST 2020
82
83              [Unit]
84              Description=Podman container-de1e3223b1b888bc02d0962dd6cb5855eb00734061013ffdd3479d225abacdc6.service
85              Documentation=man:podman-generate-systemd(1)
86
87              [Service]
88              Restart=always
89              ExecStart=/usr/bin/podman start de1e3223b1b888bc02d0962dd6cb5855eb00734061013ffdd3479d225abacdc6
90              ExecStop=/usr/bin/podman stop -t 1 de1e3223b1b888bc02d0962dd6cb5855eb00734061013ffdd3479d225abacdc6
91              KillMode=none
92              Type=forking
93              PIDFile=/run/user/1000/overlay-containers/de1e3223b1b888bc02d0962dd6cb5855eb00734061013ffdd3479d225abacdc6/userdata/conmon.pid
94
95              [Install]
96              WantedBy=multi-user.target default.target
97
98
99
100       Create systemd unit files for a pod with two simple alpine  containers.
101       Note  that  these container services cannot be started or stopped indi‐
102       vidually via systemctl; they are managed by the pod  service.  You  can
103       still use systemctl status or journalctl to examine them.
104
105
106              $ podman pod create --name systemd-pod
107              $ podman create --pod systemd-pod alpine top
108              $ podman create --pod systemd-pod alpine top
109              $ podman generate systemd --files --name systemd-pod
110              /home/user/pod-systemd-pod.service
111              /home/user/container-amazing_chandrasekhar.service
112              /home/user/container-jolly_shtern.service
113              $ cat pod-systemd-pod.service
114              # pod-systemd-pod.service
115              # autogenerated by Podman 1.8.0
116              # Wed Mar 09 09:52:37 CEST 2020
117
118              [Unit]
119              Description=Podman pod-systemd-pod.service
120              Documentation=man:podman-generate-systemd(1)
121              Requires=container-amazing_chandrasekhar.service container-jolly_shtern.service
122              Before=container-amazing_chandrasekhar.service container-jolly_shtern.service
123
124              [Service]
125              Restart=on-failure
126              ExecStart=/usr/bin/podman start 77a818221650-infra
127              ExecStop=/usr/bin/podman stop -t 10 77a818221650-infra
128              KillMode=none
129              Type=forking
130              PIDFile=/run/user/1000/overlay-containers/ccfd5c71a088768774ca7bd05888d55cc287698dde06f475c8b02f696a25adcd/userdata/conmon.pid
131
132              [Install]
133              WantedBy=multi-user.target default.target
134
135
136

SEE ALSO

138       podman(1),  podman-container(1),  systemctl(1),  systemd.unit(5),  sys‐
139       temd.service(5)
140
141

HISTORY

143       August 2019, Updated with pod support by Valentin Rothberg (rothberg at
144       redhat  dot com) April 2019, Originally compiled by Brent Baude (bbaude
145       at redhat dot com)
146
147
148
149                                                  podman-generate-systemd(1)()
Impressum