1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

proxmox4.1でLXDを動かす

1
Last updated at Posted at 2015-12-21

ubuntuはパッケージが用意されているが、debianには用意されていないので調査した。

参考

インストール

/etc/apt/sources.list.d/pve-enterprise.list
- deb https://enterprise.proxmox.com/debian jessie pve-enterprise
+ deb http://download.proxmox.com/debian jessie pve-no-subscription
lxdビルドに必要なパッケージ
apt-get install \
  pkg-config golang lxc-pve-dev build-essential

ビルド

~/.bashrc
export GOPATH=~/go
export PATH=$PATH:$GOPATH/bin/
source ~/.bashrc

mkdir ~/go
go get github.com/lxc/lxd
cd $GOPATH/src/github.com/lxc/lxd
make
  • ~/go/bin/lxdが生成される。

LXDデーモン起動

起動
sudo -E $GOPATH/bin/lxd --group sudo

cronで起動する場合

/etc/sudoers.d/user1
user1 ALL=(ALL) NOPASSWD:SETENV: /home/user1/go/bin/lxd
~/bin/lxd-daemon-start.sh
export GOPATH=/home/user1/go
export PATH=$PATH:$GOPATH/bin/
sudo -E $GOPATH/bin/lxd --group sudo
crontab(user1の)
@reboot ~/bin/lxd-daemon-start.sh

ネットワーク設定

lxc profile edit default
name: default
config: {}
devices:
  eth0:
    nictype: bridged
-   parent: lxcbr0
+   parent: docker0
    type: nic

データの場所

  • /var/lib/lxd/ にコンテナのデータが格納される。
  • /スライスの空き容量が気になるので、/var/lib/vz/lxdに移動する。
cd  /var/lib/
mv lxd vz
ln -s vz/lxd .

LXDコンテナ起動

lxc remote add images images.linuxcontainers.org
# lxc launch images:centos/7/amd64 centos
lxc launch images:ubuntu/xenial/amd64 ubuntu
ubuntuコンテナに接続
lxc exec ubuntu -- /bin/bash

ubuntuコンテナのネットワーク設定

  • proxmoxのdocker0が172.17.0.1/24とする。
ubuntuコンテナで実施
ip addr add 172.17.0.222/24 dev eth0
ip route add default via 172.17.0.1
echo "nameserver 8.8.8.8" > /etc/resolv.conf

のようにIPを手で設定しても良いが、自動で設定されるように設定する。

/etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
    address 172.17.0.222
    netmask 255.255.255.0
    gateway 172.17.0.1
    dns-nameservers 8.8.8.8 8.8.4.4
lxc restart ubuntu
lxc list

IPアドレスが設定されたことを確認。

確認
$ lxc list
+--------+---------+---------------------+------+-----------+-----------+
|  NAME  |  STATE  |        IPV4         | IPV6 | EPHEMERAL | SNAPSHOTS |
+--------+---------+---------------------+------+-----------+-----------+
| ubuntu | RUNNING | 172.17.0.2 (eth0)   |      | NO        |         0 |
+--------+---------+---------------------+------+-----------+-----------+
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?