$ mkdir /tmp/httpbin $ ctr images mount docker.io/kennethreitz/httpbin:latest /tmp/httpbin
$ ls -l /tmp/httpbin/ total 80 drwxr-xr-x 2 root root 4096 Oct 18 2018 bin drwxr-xr-x 2 root root 4096 Apr 24 2018 boot drwxr-xr-x 4 root root 4096 Oct 18 2018 dev drwxr-xr-x 1 root root 4096 Oct 24 2018 etc drwxr-xr-x 2 root root 4096 Apr 24 2018 home drwxr-xr-x 3 root root 4096 Oct 24 2018 httpbin ...
$ ctr images unmount /tmp/httpbin
要使用删除镜像 ctr,请运行:
$ ctr images remove docker.io/library/nginx:1.21
使用 ctr 处理容器
你可以运行一个容器用ctr run image-ref container-id。例如:
$ ctr run --rm -t docker.io/library/debian:latest cont1
请注意,ctr 与用户友好地 docker run 为您生成唯一容器 ID 不同,您必须自己提供唯一容器 ID。该 ctr run 命令还只支持一些熟悉的 docker run 标志:--env,-t,--tty,-d,--detach,--rm等,但没有端口指定或自动重启容器--restart=always。
与镜像类似,您可以使用以下命令列出现有容器:
$ ctr containers ls
有趣的是,该 ctr run 命令实际上是快捷方式ctr container create + ctr task start: