Barge(Docker ホスト用軽量 OS) を試してみる

Qiitaで以下の記事を見つけました。

Barge(Docker ホスト用軽量 OS)って?
http://qiita.com/A-I/items/8dc7ddc52e6038b5c74b


fmfm、たった13MB のDockerホスト用 LinuxOSだって!
これは試してみるしかない!

ISOを作ってみる
以下の手順でisoが作れるっぽいぞ。ってことでやってみました。
https://github.com/bargees/barge-os/blob/master/docs/build.md

■ViertualBoxで試してみる
VirtualBox上の Ubuntu16.04 Desktop で試してみました。

まずは必要そうなソフトを入れておきます。

apt-get update
apt-get upgrade -y
apt-get install -y git make vagrant virtualbox

おもむろに実行!

root@ubuntu:~/barge# make vagrant
vagrant resume barge
No usable default provider could be found for your system.

Vagrant relies on interactions with 3rd party systems, known as
"providers", to provide Vagrant with resources to run development
environments. Examples are VirtualBox, VMware, Hyper-V.

The easiest solution to this message is to install VirtualBox, which
is available for free on all major platforms.

If you believe you already have a provider available, make sure it
is properly installed and configured. You can see more details about
why a particular provider isn't working by forcing usage with
`vagrant up --provider=PROVIDER`, which should give you a more specific
error message for that particular provider.
Makefile:58: ターゲット 'vagrant' のレシピで失敗しました
make: [vagrant] エラー 1 (無視されました)
vagrant reload barge
No usable default provider could be found for your system.

Vagrant relies on interactions with 3rd party systems, known as
"providers", to provide Vagrant with resources to run development
environments. Examples are VirtualBox, VMware, Hyper-V.

The easiest solution to this message is to install VirtualBox, which
is available for free on all major platforms.

If you believe you already have a provider available, make sure it
is properly installed and configured. You can see more details about
why a particular provider isn't working by forcing usage with
`vagrant up --provider=PROVIDER`, which should give you a more specific
error message for that particular provider.
Makefile:58: ターゲット 'vagrant' のレシピで失敗しました
make: [vagrant] エラー 1 (無視されました)
vagrant up --no-provision barge
No usable default provider could be found for your system.

Vagrant relies on interactions with 3rd party systems, known as
"providers", to provide Vagrant with resources to run development
environments. Examples are VirtualBox, VMware, Hyper-V.

The easiest solution to this message is to install VirtualBox, which
is available for free on all major platforms.

If you believe you already have a provider available, make sure it
is properly installed and configured. You can see more details about
why a particular provider isn't working by forcing usage with
`vagrant up --provider=PROVIDER`, which should give you a more specific
error message for that particular provider.
Makefile:58: ターゲット 'vagrant' のレシピで失敗しました
make: *** [vagrant] エラー 1vagrant box add ailispaw/barge


root@ubuntu:~/barge# make
stat: '%m' に関するファイルシステム情報を読み込むことができません: そのようなファイルやディレクトリはありません
stat: '%m' に関するファイルシステム情報を読み込むことができません: そのようなファイルやディレクトリはありません
/bin/sh: 1: [: Illegal number: Inodes: Total: 1232160    Free: 1170789
/bin/sh: 1: docker: not found
/bin/sh: 3: docker: not found
/bin/sh: 4: docker: not found
Makefile:26: ターゲット 'build' のレシピで失敗しました
make: *** [build] エラー 127

あれ?なんか失敗したっぽい。
よくわかんないなぁ。。


Vagrant Boxを使ってみる

以下ページを見ると
Vagrant ですぐに起動できるっぽいので早速やってみました。
https://atlas.hashicorp.com/ailispaw/boxes/barge

■ViertualBoxで試してみる
VirtualBox上の Ubuntu16.04 Desktop で試してみました。
まず前準備

sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get install -y vagrant virtualbox make git 

準備完了後
資料どおりにオペレーションしてみます。

$ vagrant box add ailispaw/barge
$ vagrant init -m ailispaw/barge
$ vagrant up

途中までは問題なく動くのですが
Vagrant up するとフリーズしてしまいます。
ずーっと待つとtimeout。なんかうまくいってないっぽい

調べてみたら以下のページを発見
なんと!VMWareじゃないとだめっぽい!

仮想化ソフトが、ハードウェア仮想化支援機能(Intel VT や AMD-V)を仮想化してホストOS上でも有効にできるのであれば、Nested Virtualization が可能になります。

調べた範囲だと、VMware Player では Nested Virtualization が可能でしたが、VirtualBox では不可能でした。 なので、ホストOS(Windows)上で VMware、ゲストOS(Ubuntu)上で VirtualBox を起動するようにすると、仮想マシン上で Vagrant を使えました。

http://itiut.hatenablog.com/entry/2013/09/29/150714


VMWareで試してみる

VMWare上の Ubuntu16.04 Desktop で試してみました。
でも VMWareでも同じ場所でタイムアウト

ちょっと調べてみたところ、IntelVx-T 設定を有効になっていない。
以下のページを参考に 以下のようにIntelVx-T 設定を有効にしてみました。
http://did2memo.net/2015/07/10/virtualbox-64-bit-os/

# vagrant up
# vagrant ssh

うごきました!


■ISOも作ってみます(再挑戦)
NFSがインストールされていないとうまくビルドできないようなのでインストール

sudo apt-get -y install nfs-kernel-server
$ git clone https://github.com/bargees/barge
$ cd barge
$ make vagrant
vagrant resume barge
==> barge: VM not created. Moving on...
vagrant reload barge
==> barge: VM not created. Moving on...
vagrant up --no-provision barge
Bringing machine 'barge' up with 'virtualbox' provider...
==> barge: Importing base box 'ailispaw/barge'...
==> barge: Matching MAC address for NAT networking...
==> barge: Checking if box 'ailispaw/barge' is up to date...
==> barge: Setting the name of the VM: barge_barge_1478749967188_43666
==> barge: Clearing any previously set network interfaces...
==> barge: Preparing network interfaces based on configuration...
    barge: Adapter 1: nat
    barge: Adapter 2: hostonly
==> barge: Forwarding ports...
    barge: 2375 (guest) => 2375 (host) (adapter 1)
    barge: 22 (guest) => 2222 (host) (adapter 1)
==> barge: Running 'pre-boot' VM customizations...
==> barge: Booting VM...
==> barge: Waiting for machine to boot. This may take a few minutes...
    barge: SSH address: 127.0.0.1:2222
    barge: SSH username: bargee
    barge: SSH auth method: private key
    barge: 
    barge: Vagrant insecure key detected. Vagrant will automatically replace
    barge: this with a newly generated keypair for better security.
    barge: 
    barge: Inserting generated public key within guest...
    barge: Removing insecure key from the guest if it's present...
    barge: Key inserted! Disconnecting and reconnecting using new SSH key...
==> barge: Machine booted and ready!
==> barge: Setting hostname...
==> barge: Configuring and enabling network interfaces...
==> barge: Exporting NFS shared folders...
==> barge: Preparing to edit /etc/exports. Administrator privileges will be required...
● nfs-server.service - NFS server and services
   Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset: enabled)
   Active: active (exited) since Wed 2016-11-09 19:51:52 PST; 1min 20s ago
 Main PID: 5466 (code=exited, status=0/SUCCESS)

Nov 09 19:51:52 ubuntu systemd[1]: Starting NFS server and services...
Nov 09 19:51:52 ubuntu exportfs[5462]: exportfs: can't open /etc/exports fo...ng
Nov 09 19:51:52 ubuntu systemd[1]: Started NFS server and services.
Nov 09 19:51:52 ubuntu systemd[1]: Started NFS server and services.
Hint: Some lines were ellipsized, use -l to show in full.
==> barge: Mounting NFS shared folders...
==> barge: Machine not provisioned because `--no-provision` is specified.
vagrant provision barge
vagrant ssh barge -c 'sudo mkdir -p /mnt/sda1/ccache'
Connection to 127.0.0.1 closed.


$ make
stat: cannot read file system information for '%m': No such file or directory
stat: cannot read file system information for '%m': No such file or directory
/bin/sh: 1: [: Illegal number: Inodes: Total: 3211264    Free: 3016117
/bin/sh: 1: docker: not found
/bin/sh: 3: docker: not found
/bin/sh: 4: docker: not found
Makefile:26: recipe for target 'build' failed
make: *** [build] Error 127

あれ? うまくいかないなぁ・・・
何かが足りないのかな?

(後で調べる・・・かも)

Docker version を切り替えてみる

$ vagrant ssh

Welcome to Barge 2.2.7, Docker version 1.10.3, build 20f81dd
[bargee@barge ~]$ docker version
Client:
 Version:      1.10.3
 API version:  1.22
 Go version:   go1.7.3
 Git commit:   20f81dd
 Built:        Tue Nov  1 05:10:27 UTC 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.10.3
 API version:  1.22
 Go version:   go1.7.3
 Git commit:   20f81dd
 Built:        Tue Nov  1 05:10:27 UTC 2016
 OS/Arch:      linux/amd64
[bargee@barge ~]$ sudo /etc/init.d/docker restart v1.12.3
docker[395]: Loading /etc/default/docker
WARNING: Possible Forward-Incompatibility of libnetwork
Once you upgrade Docker to v1.12 or newer, if you downgrade back,
you may need to initialize /var/lib/docker/network/files/local-kv.db.
Downloading v1.12.3 ...
docker[395]: Stopping Docker daemon
docker[395]: Setting ulimit 1048576
docker[395]: DOCKER_RAMDISK=
docker[395]: Docker version 1.12.3, build 6b644ec
docker[395]: Starting Docker daemon -D -s overlay -g "/var/lib/docker" -H unix:// -H tcp://0.0.0.0:2375 --userland-proxy=false
[bargee@barge ~]$ docker version
Client:
 Version:      1.12.3
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   6b644ec
 Built:        Wed Oct 26 23:26:11 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.12.3
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   6b644ec
 Built:        Wed Oct 26 23:26:11 2016
 OS/Arch:      linux/amd64

すごい!簡単に切り替わった!