Contenu connexe Similaire à Ubuntuとコンテナ技術 What is LXD? and Why? 2015-12-08 (20) Ubuntuとコンテナ技術 What is LXD? and Why? 2015-12-085. 1
2
3
LXD (“lex-dee”)
Secure by design(セキュア)
非特権コンテナ、リソースの制限、などなど
Scalable(スケーラブル)
ノートPC上での検証から数千台規模の物理マシンクラスタまで
Intuitive(直感的)
シンプルかつ明快なAPI、コマンド
ubuntu.com/lxd
linuxcontainers.org/lxd
github.com/lxc/lxd
高速、高集積かつセキュアなコンテナマネジメントシステム
6. ● “Docker is an amazing application delivery mechanism,
which may change the world of devops forever”
● “LXD and Docker share some underlying kernel
capabilities”
And Docker?
安心してください、どちらも使えます
8. 1 2 3
LXD is not...
LXDは完全仮想化を
提供するものではあ
りません
あくまでコンテナなの
で物理マシンと同等
のパフォーマンスが出
ます。
LXDはLXCを置き換
えるプロジェクトで
はありません
LXDはLXCを補完す
るもので、LXDはコン
テナを作成/管理する
ためにliblxcを使って
います。
LXDはアプリケーショ
ンコンテナ管理ツール
ではありません
LXDはコンテナの中で動
いているものには関知せ
ず、システムコンテナ自
体を管理します。
勘違いしないために、「LXDが何ではないのか」の正しい理解を
15. LXDのインストール方法
## "lxd"パッケージのインストール
## Ubuntu 15.10のクラウドイメージではデフォルトインストール済み
$ sudo apt-get install lxd
$ newgrp lxd
## イメージダウンロードサーバーを登録
$ lxc remote add images images.linuxcontainers.org
## 最新のLXDを使いたい場合は
## $ sudo apt-add-repository ppa:ubuntu-lxc/lxd-stable
Ubuntuの場合
17. はじめてのコンテナ
## リモートイメージサーバーの情報
$ lxc remote list
## 使用できるイメージの一覧
$ lxc image list images: | less -S
## Ubuntu 14.04 LTS コンテナの起動
$ lxc launch images:ubuntu/trusty/amd64 demo1
18. コンテナ情報
## コンテナ一覧
$ lxc list
## …デバッグを見てみると
$ lxc list --debug
$ jq .
## コンテナ情報
$ lxc info demo1
$ pgrep -af /sbin/init
$ ps fax | less -S
$ lxc config show demo1
19. コンテナ内へ
## コンテナでbashを起動
$ lxc exec demo1 -- bash
# exit
## コンテナ内でコマンドを実行
$ lxc exec demo1 -- touch foo
$ lxc exec demo1 -- ls -l
## ファイルのpush/pull
$ lxc file push --mode=0600 /etc/hosts demo1/tmp/
$ lxc exec demo1 -- ls -l /tmp
$ lxc file pull demo1/etc/hosts .
20. スナップショット
## スナップショットの保存
$ lxc snapshot demo1 good
## コンテナの破壊
$ lxc exec demo1 -- rm -rf /usr
$ lxc exec demo1 -- ls /usr
## スナップショットから復元
$ lxc restore demo1 good
$ lxc exec demo1 -- ls /usr
21. リソースの制限
## CPU、メモリ情報の確認
$ lxc exec demo1 -- grep -c processor /proc/cpuinfo
$ lxc exec demo1 -- free -h
## CPU、メモリの制限を追加
$ lxc config set demo1 limits.cpus 1
$ lxc config set demo1 limits.memory 512M
$ lxc restart demo1
## 制限が反映されていることを確認
$ lxc exec demo1 -- grep -c processor /proc/cpuinfo
$ lxc exec demo1 -- free -h
22. あとはどんどん作るだけ
## イメージにエイリアスを設定
$ lxc image list
$ lxc image alias create ubuntu 76668f72d313
## 2コンテナ目以降を起動
$ lxc launch ubuntu demo2
$ lxc launch ubuntu demo3
## コマンド一覧は
$ lxc help