Vagrant1.4で走らせたCentOS6.5にDockerをインストールしたメモ
色々な人がブログをポストしてますね。Let me do it as well :)
環境はOSX10.9上です。
1. Vagarntのインストール
http://www.vagrantup.com/でdmgをダウンロードしてきてインストール
今回私は前回作成したboxイメージを利用しました。
$ vagrant init virtualbox_virtualbox.box # wired box name... anyway..
$ varant up
...
There are errors in the configuration of this machine. Please fix
the following errors and try again:
vm:
* The box 'virtualbox_virtualbox.box' could not be found.
ちなみにboxはaddしないと上記のようなエラーがでます。なのでaddします。
$ vagrant add box virtual virtualbox_virtualbox.box
$ vagrant box list
centos6.4 (virtualbox)
micro (aws)
virtual (virtualbox)
# make sure that virtual is appeared in box list command
$ vagrant ssh # ok, let's ssh to vagrant :)
2. Dockerをインストール
最近インストールドキュメントが公式ページに追加させましたね - http://docs.docker.io/en/latest/installation/rhel/ - これに沿ってすすめます。
# on vagrant that i just created.
$ sudo yum -y upgrade
# the procedure said epel should be installed but it seems that it's already there?
$ sudo rpm -ivh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/i386/epel- release-6-8.noarch.rpm
http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/i386/epel-release-6-8.noarch.rpm を取得中
準備中... ########################################### [100%]
パッケージ epel-release-6-8.noarch は既にインストールされています。
$ sudo yum -y install docker-io
...
=============================================================================================
Installing:
docker-io x86_64 0.7.0-14.el6 epel 2.3 M
Installing for dependencies:
libcgroup x86_64 0.40.rc1-5.el6_5.1 updates 125 k
lxc x86_64 0.9.0-2.el6 epel 78 k
lxc-libs x86_64 0.9.0-2.el6 epel 116 k
....
$ sudo service docker start
Starting cgconfig service: [ OK ]
Starting docker: [ OK ]
$ ps -ef | grep docker # ok,
root 11566 1 1 10:59 pts/0 00:00:00 /usr/bin/docker -d
vagrant 11663 1911 0 10:59 pts/0 00:00:00 grep docker
3. 使ってみる
$ sudo docker run -i -t centos /bin/bash
Unable to find image 'centos' (tag: latest) locally
Pulling repository centos
...
bash-4.1# cat /etc/centos-release
CentOS release 6.4 (Final)
おまけ
次からdockerがあるイメージを作るために下記のようなprovion scriptをpacker.jsonに書いておいた
$ cat provisioners/docker.sh
# Install docker
yum -y upgrade
rpm -ivh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/i386/epel-release-6-8.noarch.rpm
yum -y install docker-io
sudo chkconfig docker on
kamesho@air79.local:/Users
$ cat packer.json
...
"provisioners": [
{
"type": "shell",
"only": ["virtualbox"],
"scripts": [
"./provisioners/base.sh",
"./provisioners/vagrant.sh",
"./provisioners/virtualbox.sh",
"./provisioners/docker.sh",
"./provisioners/cleanup.sh"
],
....