|
2 | 2 | title: containerd image store with Docker Engine |
3 | 3 | linkTitle: containerd image store |
4 | 4 | weight: 50 |
5 | | -keywords: containerd, snapshotters, image store, docker engine |
6 | | -description: Learn how to enable the containerd image store on Docker Engine |
| 5 | +keywords: containerd, snapshotters, image store, docker engine, migration |
| 6 | +description: Learn about the containerd image store and how to migrate to it |
7 | 7 | aliases: |
8 | 8 | - /storage/containerd/ |
9 | 9 | --- |
10 | 10 |
|
11 | | -{{< summary-bar feature_name="containerd" >}} |
| 11 | +The containerd image store is the default storage backend for Docker Engine |
| 12 | +29.0 and later on fresh installations. If you upgraded from an earlier version, |
| 13 | +your daemon continues using the legacy graph drivers (overlay2) until you |
| 14 | +migrate. |
12 | 15 |
|
13 | 16 | containerd, the industry-standard container runtime, uses snapshotters instead |
14 | | -of the classic storage drivers for storing image and container data. |
15 | | -While the `overlay2` driver still remains the default driver for Docker Engine, |
16 | | -you can opt in to using containerd snapshotters as an experimental feature. |
| 17 | +of classic storage drivers for storing image and container data. |
17 | 18 |
|
18 | | -To learn more about the containerd image store and its benefits, refer to |
19 | | -[containerd image store on Docker Desktop](/manuals/desktop/features/containerd.md). |
| 19 | +> [!NOTE] |
| 20 | +> The containerd image store is not available when using user namespace |
| 21 | +> remapping (`userns-remap`). See |
| 22 | +> [moby#47377](https://github.com/moby/moby/issues/47377) for details. |
| 23 | +
|
| 24 | +## Why use the containerd image store |
| 25 | + |
| 26 | +The containerd image store uses snapshotters to manage how image layers are |
| 27 | +stored and accessed on the filesystem. This differs from the classic graph |
| 28 | +drivers like overlay2. |
| 29 | + |
| 30 | +The containerd image store enables: |
| 31 | + |
| 32 | +- Building and storing multi-platform images locally. With classic storage |
| 33 | + drivers, you need external builders for multi-platform images. |
| 34 | +- Working with images that include attestations (provenance, SBOM). These use |
| 35 | + image indices that the classic store doesn't support. |
| 36 | +- Running Wasm containers. The containerd image store supports WebAssembly |
| 37 | + workloads. |
| 38 | +- Using advanced snapshotters. containerd supports pluggable snapshotters that |
| 39 | + provide features like lazy-pulling of images (stargz) or peer-to-peer image |
| 40 | + distribution (nydus, dragonfly). |
| 41 | + |
| 42 | +For most users, the migration is transparent. The storage backend changes, but |
| 43 | +your workflows remain the same. |
20 | 44 |
|
21 | 45 | ## Enable containerd image store on Docker Engine |
22 | 46 |
|
23 | | -Switching to containerd snapshotters causes you to temporarily lose images and |
24 | | -containers created using the classic storage drivers. |
25 | | -Those resources still exist on your filesystem, and you can retrieve them by |
26 | | -turning off the containerd snapshotters feature. |
| 47 | +If you're upgrading from an earlier Docker Engine version, you need to manually |
| 48 | +enable the containerd image store. |
| 49 | + |
| 50 | +> [!IMPORTANT] |
| 51 | +> Switching storage backends temporarily hides images and containers created |
| 52 | +> with the other backend. Your data remains on disk. To access the old images |
| 53 | +> again, switch back to your previous storage configuration. |
| 54 | +
|
| 55 | +Add the following configuration to your `/etc/docker/daemon.json` file: |
| 56 | + |
| 57 | +```json |
| 58 | +{ |
| 59 | + "features": { |
| 60 | + "containerd-snapshotter": true |
| 61 | + } |
| 62 | +} |
| 63 | +``` |
| 64 | + |
| 65 | +Save the file and restart the daemon: |
| 66 | + |
| 67 | +```console |
| 68 | +$ sudo systemctl restart docker |
| 69 | +``` |
| 70 | + |
| 71 | +After restarting the daemon, verify you're using the containerd image store: |
| 72 | + |
| 73 | +```console |
| 74 | +$ docker info -f '{{ .DriverStatus }}' |
| 75 | +[[driver-type io.containerd.snapshotter.v1]] |
| 76 | +``` |
| 77 | + |
| 78 | +Docker Engine uses the `overlayfs` containerd snapshotter by default. |
| 79 | + |
| 80 | +## Migrate from overlay2 to containerd image store |
27 | 81 |
|
28 | | -The following steps explain how to enable the containerd snapshotters feature. |
| 82 | +Docker Engine provides an automatic migration feature to help you switch from |
| 83 | +the legacy overlay2 driver to the containerd image store. |
29 | 84 |
|
30 | | -1. Add the following configuration to your `/etc/docker/daemon.json` |
31 | | - configuration file: |
| 85 | +### Basic migration |
| 86 | + |
| 87 | +To migrate automatically when you remove all images and containers: |
| 88 | + |
| 89 | +1. Add the migration feature to your `/etc/docker/daemon.json`: |
32 | 90 |
|
33 | 91 | ```json |
34 | 92 | { |
35 | 93 | "features": { |
36 | | - "containerd-snapshotter": true |
| 94 | + "containerd-migration": true |
37 | 95 | } |
38 | 96 | } |
39 | 97 | ``` |
40 | 98 |
|
41 | | -2. Save the file. |
42 | | -3. Restart the daemon for the changes to take effect. |
| 99 | +2. Remove all images and containers: |
| 100 | + |
| 101 | + ```console |
| 102 | + $ docker rm -f $(docker ps -aq) |
| 103 | + $ docker rmi -f $(docker images -q) |
| 104 | + ``` |
| 105 | + |
| 106 | +3. Restart the daemon: |
43 | 107 |
|
44 | 108 | ```console |
45 | 109 | $ sudo systemctl restart docker |
46 | 110 | ``` |
47 | 111 |
|
48 | | -After restarting the daemon, running `docker info` shows that you're using |
49 | | -containerd snapshotter storage drivers. |
| 112 | +After restart, the daemon uses the containerd image store. Your old overlay2 |
| 113 | +data remains on disk but is hidden. If you switch back to overlay2, that data |
| 114 | +becomes accessible again. |
| 115 | + |
| 116 | +### Threshold-based migration |
| 117 | + |
| 118 | +For daemons with existing images, you can set a size threshold for automatic |
| 119 | +migration. If your graph driver content doesn't exceed the threshold, the |
| 120 | +daemon migrates automatically on restart. |
| 121 | + |
| 122 | +Set the `DOCKER_MIGRATE_SNAPSHOTTER_THRESHOLD` environment variable in your |
| 123 | +daemon's environment. For systemd, use `systemctl edit`: |
50 | 124 |
|
51 | 125 | ```console |
52 | | -$ docker info -f '{{ .DriverStatus }}' |
53 | | -[[driver-type io.containerd.snapshotter.v1]] |
| 126 | +$ sudo systemctl edit docker.service |
54 | 127 | ``` |
55 | 128 |
|
56 | | -Docker Engine uses the `overlayfs` containerd snapshotter by default. |
| 129 | +Add the following in the editor that opens: |
| 130 | + |
| 131 | +```ini |
| 132 | +[Service] |
| 133 | +Environment="DOCKER_MIGRATE_SNAPSHOTTER_THRESHOLD=100GB" |
| 134 | +``` |
| 135 | + |
| 136 | +Save and close the editor, then restart the daemon: |
| 137 | + |
| 138 | +```console |
| 139 | +$ sudo systemctl restart docker |
| 140 | +``` |
| 141 | + |
| 142 | +If the overlay2 content is under 100GB, the daemon switches to the containerd |
| 143 | +image store on restart. The overlay2 data remains on disk. |
| 144 | + |
| 145 | +> [!NOTE] |
| 146 | +> Migrating with existing data leaves that data inaccessible until you switch |
| 147 | +> back to the overlay2 driver. The data isn't deleted, just hidden. If you have |
| 148 | +> local images you want to migrate to the containerd image store, export them |
| 149 | +> first with `docker save` or push them to a registry. |
| 150 | +
|
| 151 | +## Additional resources |
| 152 | + |
| 153 | +To learn more about the containerd image store and its capabilities in Docker |
| 154 | +Desktop, see |
| 155 | +[containerd image store on Docker Desktop](/manuals/desktop/features/containerd.md). |
0 commit comments