lxc/lxd

lxc/lxdの使い方

タグ linux container lxc lxd


概要

  • linux専用のコンテナソフトウェア
  • ubuntuではsnapとaptのどちらからもインストール可能であるが、snapでインストールしないと起動しなかった

インストール

ubuntu

$ sudo snap install lxd

セットアップ

初期化

$ sudo lxd init

基本的な使い方

利用できるイメージの確認

$ lxc image list images: | less

ubuntu, debianのコンテナを作成

$ lxc launch images:ubuntu/focal <container-name>
$ lxc launch images:debian/10 <container-name>

コンテナの一覧を表示

$ lxc list
+--------------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
|     NAME     |  STATE  |         IPV4          |                     IPV6                      |   TYPE    | SNAPSHOTS |
+--------------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| tecmint-con1 | RUNNING | 10.141.156.115 (eth0) | fd42:4a40:c196:73d2:216:3eff:fe83:3778 (eth0) | CONTAINER | 0         |
+--------------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| tecmint-con2 | RUNNING | 10.141.156.179 (eth0) | fd42:4a40:c196:73d2:216:3eff:febb:e5af (eth0) | CONTAINER | 0         |
+--------------+---------+-----------------------+-----------------------------------------------+-----------+-----------+

コンテナのターミナルにアクセス

$ lxc exec <container-name> bash

参考