aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman/restore.go
diff options
context:
space:
mode:
authorAdrian Reber <areber@redhat.com>2019-02-06 19:22:46 +0000
committerAdrian Reber <areber@redhat.com>2019-06-03 22:05:12 +0200
commit0028578b432d207e1e5b313c76e587eae275bdac (patch)
treef26e1c867f72d304c84ba86109a252902a50048e /cmd/podman/restore.go
parenta05cfd24bb6929ca4431f9169b9b215b0d43d91e (diff)
downloadpodman-0028578b432d207e1e5b313c76e587eae275bdac.tar.gz
podman-0028578b432d207e1e5b313c76e587eae275bdac.tar.bz2
podman-0028578b432d207e1e5b313c76e587eae275bdac.zip
Added support to migrate containers
This commit adds an option to the checkpoint command to export a checkpoint into a tar.gz file as well as importing a checkpoint tar.gz file during restore. With all checkpoint artifacts in one file it is possible to easily transfer a checkpoint and thus enabling container migration in Podman. With the following steps it is possible to migrate a running container from one system (source) to another (destination). Source system: * podman container checkpoint -l -e /tmp/checkpoint.tar.gz * scp /tmp/checkpoint.tar.gz destination:/tmp Destination system: * podman pull 'container-image-as-on-source-system' * podman container restore -i /tmp/checkpoint.tar.gz The exported tar.gz file contains the checkpoint image as created by CRIU and a few additional JSON files describing the state of the checkpointed container. Now the container is running on the destination system with the same state just as during checkpointing. If the container is kept running on the source system with the checkpoint flag '-R', the result will be that the same container is running on two different hosts. Signed-off-by: Adrian Reber <areber@redhat.com>
Diffstat (limited to 'cmd/podman/restore.go')
-rw-r--r--cmd/podman/restore.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/cmd/podman/restore.go b/cmd/podman/restore.go
index 36ae16183..828ae682f 100644
--- a/cmd/podman/restore.go
+++ b/cmd/podman/restore.go
@@ -24,10 +24,10 @@ var (
restoreCommand.InputArgs = args
restoreCommand.GlobalFlags = MainGlobalOpts
restoreCommand.Remote = remoteclient
- return restoreCmd(&restoreCommand)
+ return restoreCmd(&restoreCommand, cmd)
},
Args: func(cmd *cobra.Command, args []string) error {
- return checkAllAndLatest(cmd, args, false)
+ return checkAllAndLatest(cmd, args, true)
},
Example: `podman container restore ctrID
podman container restore --latest
@@ -44,11 +44,12 @@ func init() {
flags.BoolVarP(&restoreCommand.Keep, "keep", "k", false, "Keep all temporary checkpoint files")
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)")
markFlagHiddenForRemoteClient("latest", flags)
}
-func restoreCmd(c *cliconfig.RestoreValues) error {
+func restoreCmd(c *cliconfig.RestoreValues, cmd *cobra.Command) error {
if rootless.IsRootless() {
return errors.New("restoring a container requires root")
}
@@ -62,6 +63,11 @@ func restoreCmd(c *cliconfig.RestoreValues) error {
options := libpod.ContainerCheckpointOptions{
Keep: c.Keep,
TCPEstablished: c.TcpEstablished,
+ TargetFile: c.Import,
}
- return runtime.Restore(c, options)
+
+ if (c.Import != "") && (c.All || c.Latest) {
+ return errors.Errorf("Cannot use --import and --all or --latest at the same time")
+ }
+ return runtime.Restore(getContext(), c, options)
}