LoginSignup
3

More than 5 years have passed since last update.

ThinkPad 8 を Docker for Windows 用のタブレットとして延命させる

Posted at

以前から Docker に興味があり、ウォッチだけは続けていたところ、Docker for Mac/Windows の正式版がリリースされたので、これを機に Docker デビューすることにした。ちなみに Qiita も Markdown もこの投稿がデビュー。今さらながら Markdown すごい。

環境

  • ThinkPad 8 (Memory: 4 GB, Storage: 128 GB)
  • Windows 10 Pro x64, Version 1607
  • Docker Toolbox 未インストール

Docker for Windows のシステム要件

Getting Started with Docker for Windows では、主に以下の 2 つが Docker for Windows のシステム要件。

  • The current version of Docker for Windows runs on 64bit Windows 10 Pro, Enterprise and Education (1511 November update, Build 10586 or later). In the future we will support more versions of Windows 10.
  • The Hyper-V package must be enabled for Docker for Windows to work. The Docker for Windows installer will enable it for you, if needed. (This requires a reboot).

Hyper-V のシステム要件

一方、Windows 10 Hyper-V のシステム要件では以下の各要件が記載されており、これらの要件がほぼそのまま Docker for Windows の要件となっている模様。

ハードウェア要件

  • 第 2 レベルのアドレス変換 (SLAT) の 64 ビット プロセッサ
  • VM モニター モード拡張機能 (Intel CPU の VT-c) の CPU サポート
  • 最小 4 GB のメモリ。 仮想マシンは Hyper-V ホストとメモリを共有するため、予想される仮想ワークロードを処理するために十分なメモリを提供する必要があります。
  • 仮想化テクノロジ (マザーボードの製造元によってラベルが異なる場合があります)
  • ハードウェアによるデータ実行防止

これらの要件は systeminfo コマンドで確認できる。手元の ThinkPad 8 で実行すると以下の結果となった。

PS C:\Windows\system32> systeminfo
...
物理メモリの合計:       3,992 MB
...
Hyper-V の要件:         VM モニター モード拡張機能: はい
                        ファームウェアで仮想化が有効になっています: はい
                        第 2 レベルのアドレス変換: はい
                        データ実行防止が使用できます: はい

なぜ今さらこんなことを確認しているかというと、ThinkPad 8 の Atom プロセッサーは仮想化をサポートしていないと思い込んでいた。…が、別件で他のマシンの環境を systeminfo で確認したついでに、ふと ThinkPad 8 でも systeminfo を実行してみたところ、出力結果の Hyper-V の要件が 4 つとも はい となっていることが発覚した次第…(ThinkPad 8 を購入して2年後に気付く)。

ソフトウェア要件

  • Windows 10 Enterprise
  • Windows 10 Professional
  • Windows 10 Education

ThinkPad 8 はプリインストール OS の Windows 8.1 with Bing から無償アップグレードすると Windows 10 Home になるが、Windows 10 との付き合いは長くなりそうだし、エディションのアップグレードで Hyper-V が使えるようになるなら今後も使いみちはあるかなー、と思い Windows 10 Pro に有償 (¥13,824) アップグレードした。

Windows 10 Hyper-V のシステム要件にもちゃっかり以下が記載されている。

Windows 10 Home Edition は、Windows 10 Professional にアップグレードすることができます。 アップグレードを行うには、[設定] > [更新とセキュリティ] > [アクティブ化] の順に開きます。 ここでストアにアクセスして、アップグレードを購入することができます。

[アクティブ化] というメニューはなかったような気がするが…、具体的な手順は Office Sway の Windows 10 Home から Windows 10 Pro にアップグレードする方法に記載されている。

Docker for Windows のインストール

ようやく本題である Docker for Windows をインストールする。

Docker for Windows のダウンロード

Getting Started with Docker for Windows[Get Docker for Windows (stable)] のボタンより、stable 版をダウンロードする。

download_stable.jpg

Docker for Windows のインストール

ダウンロードした InstallDocker.msi を実行し、GUI にしたがってインストールする。インストーラーを実行した時点で以下の画面が表示されなかったら、OS のバージョン/ビルドやエディションが Docker for Windows のシステム要件を満たしていない。

docker_setup.jpg

Hyper-V を事前に有効化していない場合、Docker for Windows のインストール後に以下の画面が表示されるので、[Enable & Restart] で有効化する。この後、Hyper-V の有効化のために自動で再起動されるのでしばらく待機。

enable_hyper-v.jpg

Docker for Windows の起動確認

Docker が起動すると、タスクトレイの Docker のアイコンにマウスカーソルを合わせたときの表示が Docker is running に遷移する。また、同アイコンを右クリック > [Settings] を表示すると、画面左下にも Docker is running が表示された状態となる。

check_running.jpg

ここで、Hyper-V マネージャーを起動してみると、専用の Linux VM (MobyLinuxVM) が起動していることが確認できる。

hyper-v_manager.jpg

Docker for Windows の動作確認

Getting Started with Docker for Windows の通りに、動作確認してみる。

Docker Engine, Compose, Machine のバージョンの確認

以下、PowerShell での実行例。

PS C:\Windows\system32> docker --version
Docker version 1.12.0, build 8eab29e
PS C:\Windows\system32> docker-compose --version
docker-compose version 1.8.0, build d988a55
PS C:\Windows\system32> docker-machine --version
docker-machine.exe version 0.8.0, build b85aac1

Docker コマンドの確認

続いて、Docker コマンドの実行例。

PS C:\Windows\system32> docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
PS C:\Windows\system32> docker version
Client:
 Version:      1.12.0
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   8eab29e
 Built:        Thu Jul 28 21:15:28 2016
 OS/Arch:      windows/amd64

Server:
 Version:      1.12.0
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   8eab29e
 Built:        Thu Jul 28 21:15:28 2016
 OS/Arch:      linux/amd64
PS C:\Windows\system32> docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 1.12.0
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 0
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: null host bridge overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 4.4.15-moby
Operating System: Alpine Linux v3.4
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.952 GiB
Name: moby
ID: MMVW:52XK:H4HB:YIWZ:PHCC:BQBP:4EJH:5KDL:BICN:Z4WZ:CTDB:Y77G
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Insecure Registries:
 127.0.0.0/8

コンテナの起動

Docker Hub からイメージをダウンロードし、コンテナを起動してみる。

hello-world の実行例。

PS C:\Windows\system32> docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c04b14da8d14: Pull complete
Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
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.
 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/

ubuntu の実行例。

PS C:\Windows\system32> docker run -it ubuntu bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
952132ac251a: Pull complete
82659f8f1b76: Pull complete
c19118ca682d: Pull complete
8296858250fe: Pull complete
24e0251a0e2c: Pull complete
Digest: sha256:f4691c96e6bbaa99d99ebafd9af1b68ace2aa2128ae95a60369c506dd6e6f6ab
Status: Downloaded newer image for ubuntu:latest
root@f58f50a5a64e:/# uname -a
Linux f58f50a5a64e 4.4.15-moby #1 SMP Thu Jul 28 22:03:07 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
root@f58f50a5a64e:/# exit
exit

nginx の実行例。

PS C:\Windows\system32> docker run -d -p 80:80 --name webserver nginx
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
357ea8c3d80b: Pull complete
0fc04568277e: Pull complete
0bed9719ddcb: Pull complete
Digest: sha256:d33834dd25d330da75dccd8add3ae2c9d7bb97f502b421b02cecb6cb7b34a1b6
Status: Downloaded newer image for nginx:latest
462f3c9708bc1c5257922bd9db61a329bba628b6cdd97b48a3c57e60e91e594f

nginx のコンテナが起動したら、ブラウザを起動し localhost にアクセスしてみる。

access_nginx.jpg

docker ps でコンテナの状況を確認する。

PS C:\Windows\system32> docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                         NAMES
462f3c9708bc        nginx               "nginx -g 'daemon off"   3 minutes ago       Up 3 minutes        0.0.0.0:80->80/tcp, 443/tcp   webserver

ドライブの共有

タスクトレイの Docker のアイコンを右クリック > [Settings] > [Shared Drives] から、Docker のコンテナに共有するドライブを選択し、[Apply] をクリックして Windows のユーザーで認証する。

share_drive.jpg

Docker for Windows の初期化

動作検証などの作業でゴミがたまってしまった場合は、[Settings] > [Reset] > [Reset to factory defaults] から初期化すると良いかも。

reset_docker.jpg

トラブルシューティング

Docker for Windows のインストーラーを実行できない

Docker for Windows のインストーラーは OS のバージョンやエディションを厳密にチェックしているようで、上述のシステム要件を満たしていない場合は、インストーラーを実行した段階で以下のようなメッセージとともに門前払いされる。

Docker Setup

This version of Docker requires Windows 10 Pro, Enterprise or Education edition with a minimum build number of 10586. Please use Docker Toolbox.

https://www.docker.com/products/docker-toolbox

個人で使用するならほとんど Windows 10 Pro の一択になるが、Windows 10 ではエディションよりも OS のバージョンの方が少し複雑となっている。Windows 10 のリリース情報にあるように、2016/8 現在でバージョンが 3 つ存在する。このうち、バージョン 1507 (RTM) には Docker for Windows をインストールできない。

Version OS build 公開日 Docker for Windows
1607 14393.x 2016/8/2 インストール可
1511 10586.x 2015/11/12 インストール可
1507 (RTM) 10240.x 2015/7/29 *インストール不可

Windows 10 をバージョン 1507 のまま使い続けるケースは少ないかもしれないが、RTM のタイミングで Windows 10 のインストーラーを作成し、そのインストーラーから Windows 10 をクリーンインストールした場合に、この罠に引っかかることになる (私が)。

なお、バージョンの 4 桁の数字は Ubuntu 16.04 のように年月を表している模様。バージョン 1607 は公開日が 2016/8/2 となっているためわかりづらいが、バージョンの数字は年月を表すと覚えておけば、それぞれがいつリリースされたバージョンなのかで混乱することはなさそう。

メモリ不足で Docker を起動できない

ThinkPad 8 のように搭載メモリが少ないマシンでは、Docker for Windows をインストール後、以下の画面が表示され、Docker (Linux VM) が起動できないことがある。

not_enough_memory.jpg

ThinkPad 8 はメモリが最大で 4 GB しかないので、Docker 以外のアプリケーションを極力終了させるか、Docker の Linux VM に割り当てるメモリを減らすしかない。割り当てるメモリを減らすには、タスクトレイの Docker アイコンから [Settings] > [Advanced] を開き、メモリの割り当てを 1024 〜 1536 MB 程度に変更する。

reduce_memory.jpg

変更後、Hyper-V マネージャーから Linux VM を確認すると、メモリの割り当てが減った状態で起動されていることがわかる。

hyper-v_manager_1gb.jpg

参考

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
3