boot2docker[Docker]

このエントリーをはてなブックマークに追加


2015-07-15


そろそろ Docker を真面目に追いかけようか、ということで Mac でやるなら定番の boot2docker をインストール。

https://github.com/boot2docker/osx-installer/releases

Boot2Docker を使うと、VirtualBox と連動して、Docker を扱うことができます。

ここから、現時点での最新版である Boot2Docker-1.7.1.pkg (132MB) をダウンロード。

ダウンロードしたファイルをダブルクリックしたら、インストール開始。

これで docker クライアントがインストールされます (docker, boot2docker コマンドについては /usr/local/bin にインストールされます)

詳細については

http://docs.docker.com/installation/mac/

Docker Client / Docker Host / Docker daemon との関係がわかるので、ざっと眺めておきます。

実際のところ、boot2docker でインストールした Docker client は、VirtualBox上の Linux VM との連動がメインなので、当然VirtualBoxも必要ですが、まぁ今日日 Vagrant で散々お世話になってるかと思うので、多くの人はインストール済ですよね。

VirtualBox がインストールされている状態であれば、

Image

に書いてあるように、Quick-Start に進みます。アプリケーションフォルダにインストールされた boot2docker を起動するとターミナルが開いて、下記のようなスクリプトが実行されます。

bash
unset DYLD_LIBRARY_PATH ; unset LD_LIBRARY_PATH
mkdir -p ~/.boot2docker
if [ ! -f ~/.boot2docker/boot2docker.iso ]; then cp /usr/local/share/boot2docker/boot2docker.iso ~/.boot2docker/ ; fi
/usr/local/bin/boot2docker init
/usr/local/bin/boot2docker up
$(/usr/local/bin/boot2docker shellinit)
docker version
〜以下略〜


このスクリプトで、VirtualBoxで boot2docker-vm という仮想マシンが立ち上がります。

そのまま開いたターミナルから

$ docker run hello-world


を実行すると、こんな感じ

bash-3.2$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from hello-world
a8219747be10: Pull complete
91c95931e552: Already exists
hello-world:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
Digest: sha256:aa03e5d0d5553b4c3473e89c8619cf79df368babd18681cf5daeb82aab55838d
Status: Downloaded newer image for hello-world:latest
Hello from Docker.
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (Assuming it was not already locally available.)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

For more examples and ideas, visit:
 http://docs.docker.com/userguide/


boot2docker コマンドで、この docker が動いてる boot2docker-vm の稼働確認ができる

bash-3.2$ boot2docker status
running


ちなみに

bash-3.2$ docker version
Client version: 1.7.1
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 786b29d
OS/Arch (client): darwin/amd64
Server version: 1.7.1
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 786b29d
OS/Arch (server): linux/amd64


終了するには、boot2docker stop を実行する。

bash-3.2$ boot2docker stop
bash-3.2$ boot2docker status
poweroff


これでしばらく遊べそう



IPv4/IPv6 meter
検索キーワードは複数指定できます
ChangeLogを検索
Google
Web www.kunitake.org
思ったより安い……時もある、Amazon

カテゴリ