diff options
author | Adrian Reber <areber@redhat.com> | 2019-03-14 07:57:16 +0000 |
---|---|---|
committer | Adrian Reber <areber@redhat.com> | 2019-06-04 14:02:51 +0200 |
commit | bef83c42eaacd83fb5020395f1bbdeb9a6f0f220 (patch) | |
tree | 6cb3dac84824f26b46df353c1956d35fec067c11 /cmd/podman/restore.go | |
parent | 0e072f9a9785c67f38859ab989267397b57154c8 (diff) | |
download | podman-bef83c42eaacd83fb5020395f1bbdeb9a6f0f220.tar.gz podman-bef83c42eaacd83fb5020395f1bbdeb9a6f0f220.tar.bz2 podman-bef83c42eaacd83fb5020395f1bbdeb9a6f0f220.zip |
migration: add possibility to restore a container with a new name
The option to restore a container from an external checkpoint archive
(podman container restore -i /tmp/checkpoint.tar.gz) restores a
container with the same name and same ID as id had before checkpointing.
This commit adds the option '--name,-n' to 'podman container restore'.
With this option the restored container gets the name specified after
'--name,-n' and a new ID. This way it is possible to restore one
container multiple times.
If a container is restored with a new name Podman will not try to
request the same IP address for the container as it had during
checkpointing. This implicitly assumes that if a container is restored
from a checkpoint archive with a different name, that it will be
restored multiple times and restoring a container multiple times with
the same IP address will fail as each IP address can only be used once.
Signed-off-by: Adrian Reber <areber@redhat.com>
Diffstat (limited to 'cmd/podman/restore.go')
-rw-r--r-- | cmd/podman/restore.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/cmd/podman/restore.go b/cmd/podman/restore.go index 828ae682f..9c77d4a5e 100644 --- a/cmd/podman/restore.go +++ b/cmd/podman/restore.go @@ -45,6 +45,7 @@ func init() { flags.BoolVarP(&restoreCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of") flags.BoolVar(&restoreCommand.TcpEstablished, "tcp-established", false, "Restore a container with established TCP connections") flags.StringVarP(&restoreCommand.Import, "import", "i", "", "Restore from exported checkpoint archive (tar.gz)") + flags.StringVarP(&restoreCommand.Name, "name", "n", "", "Specify new name for container restored from exported checkpoint (only works with --import)") markFlagHiddenForRemoteClient("latest", flags) } @@ -64,6 +65,15 @@ func restoreCmd(c *cliconfig.RestoreValues, cmd *cobra.Command) error { Keep: c.Keep, TCPEstablished: c.TcpEstablished, TargetFile: c.Import, + Name: c.Name, + } + + if c.Import == "" && c.Name != "" { + return errors.Errorf("--name can only used with --import") + } + + if c.Name != "" && c.TcpEstablished { + return errors.Errorf("--tcp-established cannot be used with --name") } if (c.Import != "") && (c.All || c.Latest) { |