LoginSignup
13
13

More than 5 years have passed since last update.

ArchLinuxでLXCを動かしてみた

Last updated at Posted at 2014-10-04

dockerは使いやすいが、lxcもたまには使おう。openvzのことはもう忘れたい。。

ネットワーク設定

パッケージインストール

必須パッケージ
pacman -Sy lxc bridge-utils wget rsync
yaourt -S --noconfirm yum
vagrant用lxcプラグインインストール(vagrant使いたい人だけ。自分は入れない)
pacman -Sy vagrant
vagrant plugin install vagrant-lxc
export VAGRANT_DEFAULT_PROVIDER=lxc

コンテナ作成

centos7のコンテナの作成
MIRROR=http://ftp.jaist.ac.jp/pub/Linux/CentOS/7/os/x86_64/ \
  sudo /usr/share/lxc/templates/lxc-centos -n centos7 -R 7

コンテナ起動の前準備

/var/lib/lxc/centos7/config
+ lxc.network.type = veth
+ lxc.network.flags = up
+ lxc.network.link = br0

コンテナ起動

コンテナのrootユーザのパスワード設定
sudo chroot /var/lib/lxc/centos7/rootfs passwd
sudo lxc-start -f /var/lib/lxc/centos7/config -n centos7
# root:先ほど設定したパスワード でログイン
コンテナ操作
切断: ctrl-a, q
接続: sudo lxc-console -n centos7

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

/etc/sysconfig/network-scripts/ifcfg-eth0
- BOOTPROTO=dhcp
+ BOOTPROTO=static
+ IPADDR=192.168.100.60
+ NETMASK=255.255.255.0
+ GATEWAY=192.168.100.1
設定反映
service network restart

system.png

  • ブリッジ設定を作る前に構築したKVMがある場合、設定を以下に変更しないと起動できないので注意。

スクリーンショット 2014-10-05 8.38.41.png

13
13
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
13
13