[LXD/LXC] lxd imageのexportとimport方法

LXDのversionは3.03

LXD export

作成してあるコンテナのイメージではなくて初期起動時にダウンロードしてくるOSイメージをexportするにはlxc launchで指定するイメージ名を引数にいれてexportする。

$ lxc image export ubuntu:18.04 .

LXD import

version3.03ではtar.xzとsquashfsが作成されるのでこれを2つとも指定し、importする。aliasで名前をイメージ名を指定できる。:(コロン)は使えないので注意。

lxc image import ubuntu-18.04-server-cloudimg-amd64-lxd.tar.xz ubuntu-18.04-server-cloudimg-amd64.squashfs --alias ubuntu18.local

launchまでの速度比較

同じfingerprintのイメージをimageリストに持てないので、ubuntu16と18で比較してますが、、だいたい同じになると思います。

イメージダウンロード後にLaunch

$ time lxc launch ubuntu:16.04 default2
Creating default2
Starting default2 

real 3m32.754s
user 0m0.059s
sys 0m0.027s

約3分半。

importしてlaunch

$ time lxc image import ubuntu-18.04-server-cloudimg-amd64-lxd.tar.xz ubuntu-18.04-server-cloudimg-amd64.squashfs --alias ubuntu18.local
Image imported with fingerprint: c234ecee3baaee25db84af8e3565347e948bfceb3bf7c820bb1ce95adcffeaa8

real 0m5.358s
user 0m0.171s
sys 0m0.551s

root@ip-172-31-36-58:~# time lxc launch ubuntu18.local test
Creating test
Starting test

real 0m46.986s
user 0m0.026s
sys 0m0.005s

52秒ぐらいで2分半は早く起動できることを確認!

Related Posts