dockerをインストールした

概要

MacOS X 10.10.5 YosemiteにDockerの実行環境をインストールしました。 VirtualBoxのバージョンは、5.0.4 r102546。

Docker Toolboxインストール

boot2dockerが非奨励になり、docker-machineを使うようになっています。

Docker Toolboxをインストールしました。

DockerToolboxは、6つのモジュールをインストールします。インストール手順は、Docker Toolboxにあります。

  • Docker Machine for running the docker-machine binary
  • Docker Engine for running the docker binary
  • Docker Compose for running the docker-compose binary
  • Kitematic, the Docker GUI
  • a shell preconfigured for a Docker command-line environment
  • Oracle VM VirtualBox

brewからもインストールできるようです。

参考

インストールに成功するとdefaultという名前の仮想マシンが作成され、実行中になっています。なっていない場合には、アプリケーション/docker/Quick startを実行すると仮想マシンを作成してくれます。

$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM
default   *        virtualbox   Running   tcp://192.168.99.100:2376

仮想マシンの状態を出力します。

$ docker-machine status default
Running
$ docker-machine env default
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/Users/unokun/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"
# Run this command to configure your shell:
# eval "$(docker-machine env default)"

Docker(hello-world)を実行してみました。installの確認にもなります。

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
535020c3e8ad: Pull complete
af340544ed62: Pull complete
library/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:02fee8c3220ba806531f606525eceb83f4feb654f62b207191b1c9209188dedd
Status: Downloaded newer image for hello-world:latest

Hello from Docker.
This message shows that your installation appears to be working correctly.

ubuntuを実行しました。バージョン(12.03, 14.04など)を指定しないと最新(latest)になります。

$ docker run -it ubuntu bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
d3a1f33e8a5a: Pull complete
c22013c84729: Pull complete
d74508fb6632: Pull complete
91e54dfb1179: Pull complete
library/ubuntu: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:73fbe2308f5f5cb6e343425831b8ab44f10bbd77070ecdfbe4081daa4dbe3ed1
Status: Downloaded newer image for ubuntu:latest
root@66ff611bca13:/# uname -a
Linux 66ff611bca13 4.0.9-boot2docker #1 SMP Thu Sep 10 20:39:20 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
root@66ff611bca13:/#

仮想マシンを停止します。

$ docker-machine stop default
$ docker-machine status default
Stopped

仮想マシンを削除します。

$ docker-machine rm default

関連情報