LoginSignup
6
6

More than 5 years have passed since last update.

Boot2Docker - Installing on Windows 7

Last updated at Posted at 2015-07-17

概要

Windows7にBoot2Dockerをインストールします。

環境

  • Windows7 (64bit)
  • Virtualbox 4.3.30
  • Git for Windows (MSysGit) 1.9.5
  • Boot2Docker 1.7.1

インストール

Boot2DockerはVirtualBox、Git for Windowsなどに依存していますので先にインストールを行います。
(Boot2Dockerインストール時に同時にインストールすることも可能です。)

Virtualbox

VirtualBoxからWindows用のインストーラーをダウンロードします。
ダウンロードしたインストーラーはVirtualBox-4.3.30-101610-Win.exeでした。

インストーラーの指示に従ってVirtualboxをインストールします。

Git for Windows

Git for WindowsからWindows用のインストーラーをダウンロードします。
ダウンロードしたインストーラーはGit-1.9.5-preview20150319.exeでした。

インストーラーの指示に従ってGit for Windowsをインストールします。

Boot2Docker

DockerからWindows用のインストーラーをダウンロードします。
ダウンロードしたインストーラーはdocker-install.exeでした。

インストーラーの指示に従ってBoot2Dockerをインストールします。
インストールが終わるとデスクトップにBoot2Docker Startというアイコンが出来ますが、引き続きアップグレードを行いますのでクリックはしません。(クリックするとvmが作成されてしまいます。)

インストールが終了するとboot2dockerのインストールディレクトリに下記の実行ファイルが用意されます。
boot2dockerはこの2つ実行ファイルを使ってvmやコンテナを操作します。

  • boot2docker.exe: vmを操作する実行ファイル
  • docker.exe: dockerイメージやコンテナを操作する実行ファイル

Boot2Dockerのアップグレード

管理者モードでコマンドプロンプトを起動し、カレントディレクトリをBoot2Dockerのインストールディレクトリへ移します。

インストールディレクトリへ移動して

> cd C:\Program Files\Boot2Docker for Windows

upgradeを行います

C:\Program Files\Boot2Docker for Windows> boot2docker.exe upgrade

アップグレードが終了したらBoot2Docker StartアイコンをクリックしてVirtualbox上にboot2docker-vmを作成します。

インストール後の確認

上記のアップグレードに続いてインストール後の確認を行います。
下記のコマンドを実行してstatusがrunningとなっていることを確認します。(Virtualboxを立ち上げてboot2docker-vmが実行中か確認する方法でも構いません)

vmの実行ステータスを確認

$ boot2docker.exe status
running

バージョンを確認

$ boot2docer.exe version
Boot2Docker-cli version: v1.7.1
Git commit: 8fdc6f5

IPを確認

$ boot2docker.exe ip
192.168.59.103

boot2docker-vmの操作

boot2docker-vmとはVirtualbox上に作成された仮想マシンです。
boot2docker-vmにログインして下記のコマンドを実行するとCore LinuxというOSであることがわかります。

docker@boot2docker:~$ cat /etc/issue
Core Linux

boot2dockerコマンド

boot2docker.exeコマンドを使用してboot2docker-vmを操作します。

boot2docker-vmの操作

boot2docker.exeコマンドで行える操作の一部はVirtualboxでも行えます。

コマンドの使用方法

Usage
boot2docker.exe [<options>] <command> [<args>]

コマンドの種類

Commands:
   init                Create a new Boot2Docker VM.
   up|start|boot       Start VM from any states.
   ssh [ssh-command]   Login to VM via SSH.
   save|suspend        Suspend VM and save state to disk.
   down|stop|halt      Gracefully shutdown the VM.
   restart             Gracefully reboot the VM.
   poweroff            Forcefully power off the VM (may corrupt disk image).
   reset               Forcefully power cycle the VM (may corrupt disk image).
   delete|destroy      Delete Boot2Docker VM and its disk image.
   config|cfg          Show selected profile file settings.
   info                Display detailed information of VM.
   ip                  Display the IP address of the VM's Host-only network.
   shellinit           Display the shell commands to set up the Docker client.
   status              Display current state of VM.
   download            Download Boot2Docker ISO image.
   upgrade             Upgrade the Boot2Docker ISO image (restart if running).
   version             Display version information.

vmの起動

$ boot2docker.exe boot

vmの停止

$ boot2docker.exe halt

boot2docker-vmへsshでログインする

boot2docker.exeコマンドのsshでboot2docker-vmへログインします。

$ boot2docker.exe ssh

...省略...

_                 _   ____     _            _
| |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 1.7.1, build master : c202798 - Wed Jul 15 00:16:02 UTC 2015

Docker version 1.7.1, build 786b29d
docker@boot2docker:~$

続けてhello-worldイメージを実行してインストールが正常に行われたか確認します。
正常に実行されると下記のような表示があります。

docker@boot2docker:~$ docker run hello-world
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/

最後に不要になったコンテナとイメージを削除します。

コンテナIDを確認してrmで削除します。

docker@boot2docker:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED         STATUS                      PORTS       NAMES
e1817ab9b9f7        hello-world         "/hello"            2 minutes ago   Exited (0) 2 minutes ago                sleepy_bardeen

docker@boot2docker:~$ docker rm e1817ab9b9f7
e1817ab9b9f7

イメージIDを確認してrmで削除します。

docker@boot2docker:~$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED         VIRTUAL SIZE
hello-world         latest              91c95931e552        3 months ago    910 B

docker@boot2docker:~$ docker rm 91c95931e552
Untagged: hello-world:latest
Deleted: 91c95931e552b11604fea91c2f537284149ec32fff0f700a4769cfd31d7696ae
Deleted: a8219747be10611d65b7c693f48e7222c0bf54b5df8467d3f99003611afa1fd8

Windowsからputtyを使ってsshでログインする

boot2docker.exeコマンドの他に例えばputtyを使ってログインすることも可能です。
puttyを立ち上げ"Host Name (or IP address)"の欄に、上記で確認したvmのIPアドレスを入力します。

  • ユーザー: docker
  • パスワード: tcuser
login as: docker
docker@192.168.59.103's password: tcuser
                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
           \______ o           __/
             \    \         __/
              \____\_______/
 _                 _   ____     _            _
| |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 1.7.1, build master : c202798 - Wed Jul 15 00:16:02 UTC 2015
Docker version 1.7.1, build 786b29d
docker@boot2docker:~$

dockerコマンド

docker.exeコマンドでdockerイメージのダウンロードや実行を行うことができます。
上記のhello-worldイメージの実行例ではboot2docker-vmにログインしてからdockerコマンドを使用しましたが、vmにログインしなくても、直接docker.exeコマンドを使って同様の操作を行うことができます。

コマンドの使用方法

Usage
docker.exe [OPTIONS] COMMAND [arg...]
$ docker.exe run -it ubuntu bash
root@abf3d4059b98:/#
6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6