2014年9月1日月曜日

AzureでDockerやってみよう(IaaS)

AzureのLinux仮想マシンでも、もちろんDockerを動かす事が可能です。
今ならUbuntuの方が楽な気もしますが、ここはCentOS6.5でやってみましょう。

DockerはEPELからyumでインストールしたいので、以下のようにrpmをインストールします。

$ sudo rpm -i http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

これで、/etc/yum.repos.d/epel.repo というファイルができてEPELを利用できます。
docker-io をyumでインストールするとすぐに使えます。

$ sudo yum install docker-io
$ sudo chkconfig docker on
$ sudo service docker start

これでDockerが使えるようになります。
以下のコマンドを実行すると、Dockerイメージを勝手に取ってきてコンテナを実行します。

$ sudo docker run -i -t centos /bin/bash
Unable to find image 'centos' locally
Pulling repository centos
b157b77b1a65: Download complete 
511136ea3c5a: Download complete 
34e94e67e63a: Download complete 
bash-4.2# uname -a
Linux a9732c8635f9 2.6.32-431.17.1.el6.centos.plus.x86_64 #1 SMP Thu May 8 02:18:11 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
bash-4.2# cat /etc/redhat-release 
CentOS Linux release 7.0.1406 (Core) 

今回はCentOSのlatestを実行しているのでCentOS7ですが、kernelバージョンが2.6.32となっており、ホストのKernelと同じバージョンが実行されている事がわかります。
なお、ホストがCentOS6の場合systemdが動作しませんので、"centos:centos6"などと指定してCentOS6で運用するのが良いかと思います。

他のクラウドなどで実行されているコンテナをそのまま持ってくることが可能ですので、ぜひお試しを。

1 件のコメント:

Unknown さんのコメント...

cool!!