失敗: Alpine 3.5.1上でLXD 2.8を使おうと試行錯誤した

## 参考

* [Linux Containers - LXD - はじめに - コマンドライン](https://linuxcontainers.org/ja/lxd/getting-started-cli/)
* [Ubuntu 16.04 LTSでLXD 2.0をセットアップして使ってみる · hnakamur's blog at github](https://hnakamur.github.io/blog/2016/05/07/start-using-lxd-2.0-on-ubuntu-16.04/)

## setup-alpine

isoブートしsetup-alipine実行

1. jp
1. alpine
1. [eth0]
1. 192.168.9.51/24
1. 192.168.9.1
2. []
3. []
4. 8.8.8.8
5. password1
5. password2
6. Asia/Tokyo
7. []
8. [f]
9. [openssh]
10. [chrony]
11. sda
12. sys
13. y

reboot

## 再起動後

```bash:
vi /etc/apk/repositories
# edge をコメントアウト
apk update
# 
apk add lxc lxd
# ネットワーク設定用
apk add dnsmasq iptables ip6tables
# ブリッジインターフェース用
apk add bridge-utils
# ssl通信用
apk add ca-certificates openssl

rc-update add lxd default
```

## 起動スクリプト追加

* このままでは `service lxd start`で`lxd dameon`が起動しないため以下修正

```diff:/etc/init.d/lxd
  #!/sbin/openrc-run
  # (c) 2016 Alpine Linux
  
  command="/usr/sbin/lxd"
  command_args="${LXD_OPTIONS}"
  command_background="true"
  pidfile="/var/run/${RC_SVCNAME}.pid"
  
  depend() {
  	need net
  	use lxcfs
  	after firewall
  }
  
+ start() {
+ 	ebegin "Starting ${SVCNAME}"
+ 	start-stop-daemon --start --background --exec \
+             $command $command_args daemon
+ 	eend $?
+ }
```

## lxdの設定

```rb
# lxd daemon
service lxd start
lxd init --auto
```

```rb
$ lxc image list images: centos
+------------------------+--------------+--------+---------------------------------+--------+----------+-------------------------------+
|         ALIAS          | FINGERPRINT  | PUBLIC |           DESCRIPTION           |  ARCH  |   SIZE   |          UPLOAD DATE          |
+------------------------+--------------+--------+---------------------------------+--------+----------+-------------------------------+
| centos/6 (3 more)      | 37b6a126b5af | yes    | Centos 6 amd64 (20170211_02:16) | x86_64 | 124.95MB | Feb 11, 2017 at 12:00am (UTC) |
+------------------------+--------------+--------+---------------------------------+--------+----------+-------------------------------+
| centos/6/i386 (1 more) | b8d9470a1866 | yes    | Centos 6 i386 (20170211_02:16)  | i686   | 121.95MB | Feb 11, 2017 at 12:00am (UTC) |
+------------------------+--------------+--------+---------------------------------+--------+----------+-------------------------------+
| centos/7 (3 more)      | 3f220a619aba | yes    | Centos 7 amd64 (20170211_02:16) | x86_64 | 65.23MB  | Feb 11, 2017 at 12:00am (UTC) |
+------------------------+--------------+--------+---------------------------------+--------+----------+-------------------------------+
```

```rb
# lxc launch images:centos/6 cent01
lxc launch images:centos/6 cent01 -c security.privileged=true
lxc network attach lxdbr0 cent01
lxc start cent01 # <- 起動しない・・・。
lxc info cent01
lxc list
lxc exec cent01 -- bash # <- 起動しない・・・。
```

## lxdのアンインストール

```
rc-update del lxd default
apk del lxd
rm -r /var/lib/lxd
ip link set lxdbr0 down
brctl delbr lxdbr0
reboot
```

## トラブルシューティング

* [wget installation does not work on Alpine · Issue #73 · Yelp/dumb-init · GitHub](https://github.com/Yelp/dumb-init/issues/73)

> error: Get https://images.linuxcontainers.org/streams/v1/index.json: x509: failed to load system roots and no roots provided
> wget https://images.linuxcontainers.org/streams/v1/index.json
> wget: can't execute 'ssl_helper': No such file or directory

* ca-certificates, openssl パッケージを入れる。