最近は毎日vagrantで遊んでおります。いえ、仕事ですけど。
VirtualBox on Virtualboxとかやってると自分がどこにいるのかだんだんわからなくなってきますね。
MacではlxcできないのでゲストOSのUbuntuの中でvagrant-lxc入れてますよ。
という訳でこんな構成
ホストOS: Mac OS X Marvericks/VirtualBox4.3/Vagrang 1.3.5
ゲストOS: Ubuntu 12.04.3 LTS に vagrant-lxc 入れて container 起動
lxcコンテナ(ゲストOS上で動作): CentOS6.4
vagrantbox.es に掲載されている「lxc-centos6.4-2013-10-24.box」を使ってCentOSを動かします。
$ vagrant box add lxc-centos64 https://dl.dropboxusercontent.com/s/eukkxp5mp2l5h53/lxc-centos6.4-2013-10-24.box Downloading or copying the box... Extracting box...te: 577k/s, Estimated time remaining: 0:00:01)) Successfully added box 'lxc-centos64' with provider 'lxc'! $ vagrant init lxc-centos64 $ vagrant up --provider=lxc $ vagrant ssh [vagrant@centos6 ~]$
全く問題なく動きます!すげー!起動早い。
一度終了します。
$ vagrant halt [default] Attempting graceful shutdown of VM... $ lxc-info --name lxc-centos64_default-1384664888 state: STOPPED lxc-info: 'lxc-centos64_default-1384664888' is not running pid: -1
lxc的にも止まっています。
$ vagrant up --provider=lxc Bringing machine 'default' up with 'lxc' provider... [default] Setting up mount entries for shared folders... [default] -- /vagrant [default] Starting container... [default] Waiting for machine to boot. This may take a few minutes... [default] Machine booted and ready! $ vagrant status Current machine states: default running (lxc) $ vagrant ssh 反応なし。
起動は普通にしますがSSHできません。
$ lxc-info --name lxc-centos64_default-1384664888 lxc-info: failed to get state for 'lxc-centos64_default-1384664888': Permission denied $ sudo lxc-info --name lxc-centos64_default-1384664888 state: RUNNING pid: 5387 $ sudo lxc-attach --name lxc-centos64_default-1384664888 [root@centos6 /]# [root@centos6 /]# /sbin/ifconfig eth0 Link encap:Ethernet HWaddr 00:xx:xx:xx:xx:xx inet addr:10.0.3.249 Bcast:10.0.3.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:81 errors:0 dropped:0 overruns:0 frame:0 TX packets:68 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:14683 (14.3 KiB) TX bytes:11028 (10.7 KiB)
lxc的には動いていて、lxc-attachはできた。ネットワークも問題なさそう。
一度exitしてUbuntu側からsshしてみる。
$ ssh vagrant@10.0.3.249 (known hostsに登録確認とか略) vagrant@10.0.3.249's password: PTY allocation request failed on channel 0
でた、本題の「PTY allocation request failed on channel 0」
検索したらLXCのUsers Mailinglistにこんなのあった。
"PTY allocation request failed on channel 0 - stdin: is not a tty"
$ sudo lxc-attach --name lxc-centos64_default-1384664888 [root@centos6 /]# vim /etc/init/devpts.conf start on startup exec mount -t devpts none /dev/pts -o rw,noexec,nosuid,gid=5,mode=0620 [root@centos6 /]# exit $ vagrant halt $ vagrant up --provider=lxc $ vagrant ssh Last login: Sun Nov 17 05:10:04 2013 from 10.0.3.1 [vagrant@centos6 ~]$
きた!
ちなみに起動までは15秒くらい。
$ time vagrant up --provider=lxc Bringing machine 'default' up with 'lxc' provider... [default] Setting up mount entries for shared folders... [default] -- /vagrant [default] Starting container... [default] Waiting for machine to boot. This may take a few minutes... [default] Machine booted and ready! real 0m15.010s user 0m13.720s sys 0m0.524s
さて、なんで起動初期は接続できたのに2回目以降ダメになるのかというのがいまいち理解できていませんが
ひとまず接続できるようになったという事で。
boxは自分で作った方がいいのかなー。