Difference between revisions of "Containerd"

From CRIU
Jump to navigation Jump to search
m
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
This article describes the status of checkpoint/restore integration with [https://containerd.io/ containerd], and how to use it.
 
This article describes the status of checkpoint/restore integration with [https://containerd.io/ containerd], and how to use it.
 +
 +
One thing that may be confusing at first is the separation between a "container" and a "task" in containerd. A container is a metadata object that resources are allocated and attached to. A task is a live, running process on the system. Tasks should be deleted after each run while a container can be used, updated, and queried multiple times.
  
 
== Container Checkpoint/Restore ==
 
== Container Checkpoint/Restore ==
  
Create a container with ID "looper" based on the "ubuntu:latest" image.
+
The following example shows how to run a container from an OCI image, create a checkpoint of the running container, and restore a new container from the checkpoint.
 +
 
 +
{{Note|<code>ctr</code> is unsupported debug and administrative client for interacting with the containerd daemon. The commands, options, and operations are not guaranteed to be backward compatible or stable from release to release of the containerd project.}}
 +
 
 +
Download "redis:alpine" image if not already available locally.
 +
 
 +
ctr image pull docker.io/library/redis:alpine
  
ctr image pull docker.io/library/ubuntu:latest
+
Create and run a new container with ID "redis"
ctr run --runtime io.containerd.runc.v1 -d docker.io/library/ubuntu:latest looper /bin/sh -c 'i=0; while true; do echo $i; i=$(expr $i + 1); sleep 1; done'
 
  
 +
ctr run -d docker.io/library/redis:alpine redis
  
 
Create container checkpoint
 
Create container checkpoint
  
  ctr c checkpoint --rw --task looper checkpoint/looper:20211011
+
  ctr c checkpoint --rw --task redis checkpoint/redis:cr-1
 +
 
 +
Show information about the new checkpoint image registered with containerd
 +
 
 +
ctr images ls 'name==checkpoint/redis:cr-1'
  
Restore container from checkpoint
+
Restore container from checkpoint with new ID (redis-debug)
  
  ctr c restore looper-1 checkpoint/looper:20211011
+
  ctr c restore --rw --live redis-debug checkpoint/redis:cr-1

Latest revision as of 15:58, 16 March 2023

This article describes the status of checkpoint/restore integration with containerd, and how to use it.

One thing that may be confusing at first is the separation between a "container" and a "task" in containerd. A container is a metadata object that resources are allocated and attached to. A task is a live, running process on the system. Tasks should be deleted after each run while a container can be used, updated, and queried multiple times.

Container Checkpoint/Restore[edit]

The following example shows how to run a container from an OCI image, create a checkpoint of the running container, and restore a new container from the checkpoint.

Note.svg Note: ctr is unsupported debug and administrative client for interacting with the containerd daemon. The commands, options, and operations are not guaranteed to be backward compatible or stable from release to release of the containerd project.

Download "redis:alpine" image if not already available locally.

ctr image pull docker.io/library/redis:alpine

Create and run a new container with ID "redis"

ctr run -d docker.io/library/redis:alpine redis

Create container checkpoint

ctr c checkpoint --rw --task redis checkpoint/redis:cr-1

Show information about the new checkpoint image registered with containerd

ctr images ls 'name==checkpoint/redis:cr-1'

Restore container from checkpoint with new ID (redis-debug)

ctr c restore --rw --live redis-debug checkpoint/redis:cr-1