diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-04-22 06:24:52 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-22 06:24:52 -0400 |
commit | 26a51b29009e6250f2b52fc7c13fb1b65208754e (patch) | |
tree | 5fd96d95e5a134783d264b05db8efa86bdd59267 /cmd | |
parent | 67a1b520e38d9860345bdece2026c4f7a95cb8fd (diff) | |
parent | 5375401960cf0a9b716bb18eacdb07ffbb0e6da1 (diff) | |
download | podman-26a51b29009e6250f2b52fc7c13fb1b65208754e.tar.gz podman-26a51b29009e6250f2b52fc7c13fb1b65208754e.tar.bz2 podman-26a51b29009e6250f2b52fc7c13fb1b65208754e.zip |
Merge pull request #13943 from cdoern/clone
podman container clone -f
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/containers/clone.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/cmd/podman/containers/clone.go b/cmd/podman/containers/clone.go index 8a1473608..6912da1fc 100644 --- a/cmd/podman/containers/clone.go +++ b/cmd/podman/containers/clone.go @@ -38,6 +38,9 @@ func cloneFlags(cmd *cobra.Command) { runFlagName := "run" flags.BoolVar(&ctrClone.Run, runFlagName, false, "run the new container") + forceFlagName := "force" + flags.BoolVarP(&ctrClone.Force, forceFlagName, "f", false, "force the existing container to be destroyed") + common.DefineCreateFlags(cmd, &ctrClone.CreateOpts, false, true) } func init() { @@ -52,7 +55,7 @@ func init() { func clone(cmd *cobra.Command, args []string) error { switch len(args) { case 0: - return errors.Wrapf(define.ErrInvalidArg, "Must Specify at least 1 argument") + return errors.Wrapf(define.ErrInvalidArg, "must specify at least 1 argument") case 2: ctrClone.CreateOpts.Name = args[1] case 3: @@ -68,6 +71,10 @@ func clone(cmd *cobra.Command, args []string) error { ctrClone.RawImageName = rawImageName } } + if ctrClone.Force && !ctrClone.Destroy { + return errors.Wrapf(define.ErrInvalidArg, "cannot set --force without --destroy") + } + ctrClone.ID = args[0] ctrClone.CreateOpts.IsClone = true rep, err := registry.ContainerEngine().ContainerClone(registry.GetContext(), ctrClone) |