Skip to content

Instantly share code, notes, and snippets.

@estesp
Last active December 12, 2023 13:36
Show Gist options
  • Save estesp/a180691f632149bc409487de9498050b to your computer and use it in GitHub Desktop.
Save estesp/a180691f632149bc409487de9498050b to your computer and use it in GitHub Desktop.
example of using ctr snapshot mounts

pull an image

root@ubu1804vm:~# ctr image pull docker.io/library/redis:latest
docker.io/library/redis:latest:                                                   resolved       |+++++++++++++++++++++++++++++++docker.io/library/redis:latest:                                                   resolved       |++++++++++++++++++++++++++++++++++++++|
index-sha256:ddf831632db1a51716aa9c2e9b6a52f5035fc6fa98a8a6708f6e83033a49508d:    done           |++++++++++++++++++++++++++++++++++++++|
manifest-sha256:780f7dacdc133e899fba9ff09c099828b469030acefe6f3bbc16197b55800cfd: done           |++++++++++++++++++++++++++++++++++++++|
layer-sha256:75797de34ea7abaf8ebd484896a21f5bda63ffbcade7217dad0be0b8b8333bde:    done           |++++++++++++++++++++++++++++++++++++++|
config-sha256:f0453552d7f26fc38ffc05fa034aa7a7bc6fbb01bc7bc5a9e4b3c0ab87068627:   done           |++++++++++++++++++++++++++++++++++++++|
layer-sha256:68ced04f60ab5c7a5f1d0b0b4e7572c5a4c8cce44866513d30d9df1a15277d6b:    done           |++++++++++++++++++++++++++++++++++++++|
layer-sha256:7ecc253967df63c91c05c830bac2fe70ca6310473427da326667b44fdec3374f:    done           |++++++++++++++++++++++++++++++++++++++|
layer-sha256:765957bf98d45a3c48bc1565d2cbddfbae12a480404e11a2ad43e0e5c1513a64:    done           |++++++++++++++++++++++++++++++++++++++|
layer-sha256:91fff01e8fef842990ce8f7b4030f3e8efd21772038ab0f984a3ad943aca7e91:    done           |++++++++++++++++++++++++++++++++++++++|
layer-sha256:76feb725b7e39dd73c83d3eddaea86abcfa4b7dbb1405876f00342087b70c80b:    done           |++++++++++++++++++++++++++++++++++++++|
elapsed: 16.0s                                                                    total:  33.7 M (2.1 MiB/s)
unpacking linux/amd64 sha256:ddf831632db1a51716aa9c2e9b6a52f5035fc6fa98a8a6708f6e83033a49508d...
done

create a container

root@ubu1804vm:~# ctr container create docker.io/library/redis:latest redis
root@ubu1804vm:~# ctr c ls
CONTAINER    IMAGE                              RUNTIME
alpine       docker.io/library/alpine:latest    io.containerd.runc.v2
redis        docker.io/library/redis:latest     io.containerd.runc.v2

make a dir for the rootfs mount and then ask containerd for the mount command

root@ubu1804vm:~# mkdir redis-rootfs
root@ubu1804vm:~# ctr snapshot mounts ~/redis-rootfs/ redis | sh
root@ubu1804vm:~# cd redis-rootfs/
root@ubu1804vm:~/redis-rootfs# ls
bin  boot  data  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@ubu1804vm:~/redis-rootfs#

see info about the mount including all the overlay options

root@ubu1804vm:~/redis-rootfs# mount | grep redis
overlay on /home/estesp/redis-rootfs type overlay (rw,relatime,lowerdir=/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/115/fs:/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/114/fs:/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/113/fs:/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/112/fs:/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/111/fs:/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/110/fs,upperdir=/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/116/fs,workdir=/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/116/work)

unmount

root@ubu1804vm:~/redis-rootfs# cd ..
root@ubu1804vm:~# umount redis-rootfs
root@ubu1804vm:~#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment