LoginSignup
43
63

More than 5 years have passed since last update.

Docker for WindowsをWindows10 Proにインストール

Last updated at Posted at 2016-12-10

この記事は、「クラウド時代のシステム管理」の記事を転記したものです。

最近ではHyper-Vなどの仮想化に代わり、DockerやWindowsコンテナなどのコンテナ技術が流行っています。今回はDocker for WindowsをWindows10 Proの環境に導入してみます。

1. 前提知識・前提条件

1-1. コンテナとは

コンテナは仮想マシンよりもオーバーヘッドが少なく、OS内でプロセスを起動するような感覚で、アプリケーション実行環境を用意することが出来るため、クラウドネイティブなアプリケーションでは特に利用されやすい傾向にあります。

Windows10 ProではHyper-V、Bash on Ubuntu on Windows10、Docker for Windowsなどいろんなマルチプラットフォーム対応ツールが利用できます。

  • Hyper-V : サーバーの仮想化ソフトウェア。OSを丸ごと仮想化する。
  • Bash on Ubuntu on Windows10 : UbuntuのバイナリがWindows上で動くようAPIの読み替えをしている。正式には「Windows Subsystem for Linux」。
  • Windows Serverコンテナ : Windowsネイティブなコンテナ。Windowsカーネルベースのコンテナのみ利用可能。
  • Docker for Windows : Hyper-V上にLinux仮想マシンを作り、仮想マシン内でLinuxカーネルベースのコンテナを作る。

1-2. Docker for Windowsを利用する前提条件

Docker for Windowsはこちらのサイトで公開されています。このページ内に以下のような記述があります。

Docker for Windows requires 64bit Windows 10 Pro, Enterprise and Education (1511 November update, Build 10586 or later) and Microsoft Hyper-V. Please see What to know before you install for a full list of prerequisites.

つまり、基本的にはDocker for WindowsにはHyper-Vが必要となります。これはDocker MachineというLinuxベースの仮想マシン内でコンテナが実行されるためです。もしHyper-Vに対応していないWindows 10環境でDockerコンテナを試したい場合は、Docker Toolboxを利用します。Docker ToolboxではHyper-Vの代わりにVirtual Boxが仮想環境として利用されます。

2. Docker for Windowsのインストール

2-1. Hyper-Vの有効化

事前にHyper-Vの機能を有効化しておきます。有効化はWindowsの機能の有効化画面で可能です。

2-2. Docker for Windowsのインストールの実行

Docker for Windowsのサイトからインストーラーをダウンロードし、実行します。

docke-rinstall-wizard01

インストールには特に設定項目はなく、Insallボタンをクリックすると自動でインストールが行われます。

docke-rinstall-wizard02

インストール完了後、「Launch Docker」のチェックボックスがチェックされていることを確認します。チェックされている状態で「Finish」をクリックすると、バックグラウンドでDocker Machineの構築が開始され、数分後にDockerが利用可能な状態となります。

docke-rinstall-wizard03

2-3. Dockerの動作確認

インストール直後の状態では、Dockerはコマンドプロンプト(PowerShellではない)で実行可能です。そこで、コマンドプロンプトにてDockerの"hello-world"コンテナを実行してみます。

C:\> 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.
 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

Share images, automate workflows, and more with a free Docker Hub account:
 https://hub.docker.com

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

また、バージョン情報などを確認するためにコマンドを実行します。

C:\>docker --version
Docker version 1.12.3, build 6b644ec

C:\>docker-compose --version
docker-compose version 1.8.1, build 004ddae

C:\>docker-machine --version
docker-machine version 0.8.2, build e18a919

docker-windows-command

以上で、Windows10上で「Linux Kernelベースのコンテナ」を動かすための環境のセットアップが完了しました。

43
63
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
43
63