# Checkpoint/restore containerd

## Prerequisites

1. Create an account with Cedana, to get access to the containerd plugin. See [authentication](https://docs.cedana.ai/daemon/get-started/authentication).
2. Set the Cedana URL & authentication token in the [configuration](https://docs.cedana.ai/daemon/get-started/configuration).
3. Install the **containerd** plugin with `sudo cedana plugin install containerd`.
4. Ensure the daemon is running, see [installation](https://docs.cedana.ai/daemon/get-started/installation).
5. Do a health check to ensure the plugin is ready, see [health checks](https://docs.cedana.ai/daemon/get-started/health).

## Basic

1. Run a new containerd container, for example:

```sh
sudo ctr run docker.io/library/nginx:latest <container_id>
```

2. Checkpoint:

```sh
cedana dump containerd <container_id> --dir <dump-dir>
```

3. Restore is currently WIP. However, you can restore this container as a runc container, see [checkpoint/restore runc](https://docs.cedana.ai/daemon/checkpoint-restore/cr-2).

## Managed

1. Run a new managed containerd container:

```sh
cedana run containerd --attach --jid <job_id> --image docker.io/library/nginx:latest
```

2. Checkpoint:

```sh
cedana dump job <job_id>
```

3. Restore is currently WIP.

## GPU support

Just like for processes, as explained in [checkpoint/restore with GPUs](https://docs.cedana.ai/daemon/checkpoint-restore/cr-1), GPU support is also available for managed containerd containers.

1. Run a new managed containerd container with GPU support:

```sh
cedana run containerd --attach --gpu-enabled --jid <job_id> --image docker.io/library/nginx:latest
```

2. Checkpoint:

```sh
cedana dump job <job_id>
```

3. Restore is currently WIP.

## Rootfs

To include the rootfs in the checkpoint, additionally set the `--image` flag with a new image name. For example:

```sh
cedana dump containerd <container_id> --dir <dump-dir> --image <new-image-name>
```

For checkpoint *only* the rootfs, set the `--rootfs-only` flag. For example:

```sh
cedana dump containerd <container_id> --dir <dump-dir> --image <new-image-name> --rootfs-only
```

{% hint style="info" %}
For all available CLI options, see [CLI reference](https://docs.cedana.ai/daemon/references/cli/cedana). Directly interacting with daemon is also possible through gRPC, see [API reference](https://docs.cedana.ai/daemon/references/api).
{% endhint %}
