diff options
author | cdoern <cbdoer23@g.holycross.edu> | 2022-04-20 21:40:47 -0400 |
---|---|---|
committer | cdoern <cbdoer23@g.holycross.edu> | 2022-04-21 15:00:32 -0400 |
commit | 5375401960cf0a9b716bb18eacdb07ffbb0e6da1 (patch) | |
tree | b35639c169b65c5e5d44ccfa3e9e75fe8aa4f47f /cmd/podman | |
parent | 02ab86a68aa3c510dc8be8aefbd1029efb657438 (diff) | |
download | podman-5375401960cf0a9b716bb18eacdb07ffbb0e6da1.tar.gz podman-5375401960cf0a9b716bb18eacdb07ffbb0e6da1.tar.bz2 podman-5375401960cf0a9b716bb18eacdb07ffbb0e6da1.zip |
podman container clone -f
add the option -f to force remove the parent container if --destory is specified
resolves #13917
Signed-off-by: cdoern <cbdoer23@g.holycross.edu>
Diffstat (limited to 'cmd/podman')
-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) |