summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-05-03 23:14:12 +0200
committerGitHub <noreply@github.com>2019-05-03 23:14:12 +0200
commit4aa90145bf611a7bc08ddff7e061a630154e8b40 (patch)
tree01dc345c05b6ef2c5416eb169f0388c3afb4feb1 /cmd
parent2658e870d21dc03096740f17fa869463136d3fae (diff)
parentd3286952e6f99b3c1f8ba177d8caddc9544adea4 (diff)
downloadpodman-4aa90145bf611a7bc08ddff7e061a630154e8b40.tar.gz
podman-4aa90145bf611a7bc08ddff7e061a630154e8b40.tar.bz2
podman-4aa90145bf611a7bc08ddff7e061a630154e8b40.zip
Merge pull request #2826 from mheon/restart_policy
Add restart policy for containers
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/common.go2
-rw-r--r--cmd/podman/shared/create.go37
2 files changed, 20 insertions, 19 deletions
diff --git a/cmd/podman/common.go b/cmd/podman/common.go
index 8aca08248..c0bcaa5c5 100644
--- a/cmd/podman/common.go
+++ b/cmd/podman/common.go
@@ -444,7 +444,7 @@ func getCreateFlags(c *cliconfig.PodmanCommand) {
)
createFlags.String(
"restart", "",
- "Restart is not supported. Please use a systemd unit file for restart",
+ "Restart policy to apply when a container exits",
)
createFlags.Bool(
"rm", false,
diff --git a/cmd/podman/shared/create.go b/cmd/podman/shared/create.go
index 81566326b..d1f704374 100644
--- a/cmd/podman/shared/create.go
+++ b/cmd/podman/shared/create.go
@@ -41,6 +41,9 @@ func CreateContainer(ctx context.Context, c *GenericCLIResults, runtime *libpod.
span, _ := opentracing.StartSpanFromContext(ctx, "createContainer")
defer span.Finish()
}
+ if c.Bool("rm") && c.String("restart") != "" && c.String("restart") != "no" {
+ return nil, nil, errors.Errorf("the --rm option conflicts with --restart")
+ }
rtc, err := runtime.GetConfig()
if err != nil {
@@ -279,9 +282,6 @@ func ParseCreateOpts(ctx context.Context, c *GenericCLIResults, runtime *libpod.
blkioWeight uint16
namespaces map[string]string
)
- if c.IsSet("restart") {
- return nil, errors.Errorf("--restart option is not supported.\nUse systemd unit files for restarting containers")
- }
idmappings, err := util.ParseIDMapping(c.StringSlice("uidmap"), c.StringSlice("gidmap"), c.String("subuidname"), c.String("subgidname"))
if err != nil {
@@ -676,21 +676,22 @@ func ParseCreateOpts(ctx context.Context, c *GenericCLIResults, runtime *libpod.
PidsLimit: c.Int64("pids-limit"),
Ulimit: c.StringSlice("ulimit"),
},
- Rm: c.Bool("rm"),
- StopSignal: stopSignal,
- StopTimeout: c.Uint("stop-timeout"),
- Sysctl: sysctl,
- Systemd: systemd,
- Tmpfs: c.StringSlice("tmpfs"),
- Tty: tty,
- User: user,
- UsernsMode: usernsMode,
- MountsFlag: c.StringArray("mount"),
- Volumes: c.StringArray("volume"),
- WorkDir: workDir,
- Rootfs: rootfs,
- VolumesFrom: c.StringSlice("volumes-from"),
- Syslog: c.Bool("syslog"),
+ RestartPolicy: c.String("restart"),
+ Rm: c.Bool("rm"),
+ StopSignal: stopSignal,
+ StopTimeout: c.Uint("stop-timeout"),
+ Sysctl: sysctl,
+ Systemd: systemd,
+ Tmpfs: c.StringSlice("tmpfs"),
+ Tty: tty,
+ User: user,
+ UsernsMode: usernsMode,
+ MountsFlag: c.StringArray("mount"),
+ Volumes: c.StringArray("volume"),
+ WorkDir: workDir,
+ Rootfs: rootfs,
+ VolumesFrom: c.StringSlice("volumes-from"),
+ Syslog: c.Bool("syslog"),
}
if config.Privileged {