LoginSignup
1
2

More than 5 years have passed since last update.

Docker for Windows 導入メモ(その1)

Last updated at Posted at 2016-12-30

Docker for Windows 導入メモ(その1)

2016/12/30時点で、Windows上でDockerを使うまでのメモ。
なお、今回使うDocker for Windowsは、Hyper-V上にLinuxコンテナをセットアップするもので、MicrosoftがWindows server 2016で導入するWindows Subsystem for Linuxとは別物です。

勤務先にはOSSアレルギーの多い人間が多いので、本当はWindows Subsystem for Linuxを待ちたいところではありますが、年末年始になんとか試してみたいので、今回はDocker for Windowsです。

ソフト等 バージョン 備考
Docker for Windows v1.12.5 制限事項参照
gitbook-uml GitbookでUMLの図入のドキュメントを書く

制限事項

Docker for Windowsには、以下のような制限があるようです。

  • Windows 10の64ビット版のみ対応
  • Hyper-Vを使うため、VMware等のVM上では動作不能。 (VMの設定を修正すれば動かせますが、本筋ではないので、細部は以下のサイト等を参照願います)

基本的に、以下のサイトを参考にしました。

ダウンロード&インストール

公式のGet Docker for Windowsから、InstallDocker.msiをダウンロードして実行。(管理者権限の確認が来ますので「はい」をクリック)

image

「I aceept ~」をチェックして、「Install」ボタンをクリック。セットアップ自体はこれだけです。

image
image

1分ほどでセットアップが終わるので、「Launch Docker」をチェックしたまま「Finish」ボタンをクリック。

image

この段階でデスクトップには「Docker for Windows」のアイコンが出来ていますが、Hyper-Vの設定がまだです。
ダイアログが表示されたら、「OK」ボタンをクリックすると、しばらく設定した後、システムが再起動されます。

この時、以下のエラーが出ました。

image

Hyper-Vマネージャで確認する限り、MobyLinuxVMは動いている模様ですが、うまく接続できていないと出るエラーの模様。
あまり情報はありませんが、私はデスクトップのDocker for Windowsを起動し、SettingsのResetから「Reset to factory defaults...」を実行したところ、正常になりました。

image

単に再インストールで直ったとかいう情報もありますので、微妙な原因かもしれません。

とりあえず、PowerShellからdocker versionとか実行すると、次のように表示されるようになりました。

> docker version
Client:
 Version:      1.12.5
 API version:  1.24
 Go version:   go1.6.4
 Git commit:   7392c3b
 Built:        Fri Dec 16 06:14:34 2016
 OS/Arch:      windows/amd64

Server:
 Version:      1.12.5
 API version:  1.24
 Go version:   go1.6.4
 Git commit:   7392c3b
 Built:        Fri Dec 16 06:14:34 2016
 OS/Arch:      linux/amd64

次に、docker run で hello-worldコンテナを実行してみる。

> 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/

Dockerfileを使ってみる

一応動くようなので、さっそくですが、こちらの記事が気になっており、試そうと思います。
GitbookでUMLの図入のドキュメントを書く

右も左も分かりませんが、該当のファイルをgitHubからダウンロード&解凍し、Dockerfileのある場所で、docker-compose up viewerしてみました。
数分後、以下のエラーで停止。
(途中、文字化けしていた箇所も多数あったが、多分エラーはなかったのだろう…)

...
npm info ok
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
(1/11) Installing pixman (0.34.0-r0)
(2/11) Installing cairo (1.14.4-r0)
(3/11) Installing libintl (0.19.7-r3)
(4/11) Installing pcre (8.38-r1)
(5/11) Installing glib (2.48.0-r0)
(6/11) Installing libltdl (2.4.6-r0)
(7/11) Installing libxft (2.3.2-r0)
(8/11) Installing graphite2 (1.3.8-r0)
(9/11) Installing harfbuzz (1.2.7-r0)
(10/11) Installing pango (1.40.1-r0)
(11/11) Installing graphviz (2.38.0-r5)
Executing busybox-1.24.2-r12.trigger
Executing glib-2.48.0-r0.trigger
Executing graphviz-2.38.0-r5.trigger
OK: 175 MiB in 48 packages
 ---> 2d3a66d8d598
Removing intermediate container 0b8b5208d153
Step 14 : COPY ./gitbook.sh /usr/bin/
 ---> c181eddd121b
Removing intermediate container aff530fb7c26
Step 15 : ENTRYPOINT gitbook.sh
 ---> Running in df16ee8dbc02
 ---> 2b12c9cb7f0a
Removing intermediate container df16ee8dbc02
Step 16 : VOLUME /tmp/_book
 ---> Running in 79ac441ddc69
 ---> c415ed222081
Removing intermediate container 79ac441ddc69
Successfully built c415ed222081
WARNING: Image for service viewer was built because it did not already exist. To rebuild this image you must use `docker
-compose build` or `docker-compose up --build`.
Creating gitbookuml_viewer_1

ERROR: for viewer  Cannot create container for service viewer: C: drive is not shared. Please share it in Docker for Win
dows Settings
ERROR: Encountered errors while bringing up the project.

Docker for Windowsを起動し、SettingsのShared DrivesからCドライブのチェックを入れました。

image

なんでチェックが入っていなかったのかは不明。
Windows 10でMicrosoftアカウントとローカルマシンのパスワードがどういう管理になってるのか知らないけど、その辺が不整合起こしてたっぽい。
Microsoftアカウントのパスワードを再設定したらチェックできる様になった。
その後、上記メッセージに従い、docker-compose up --buildしたところ次のエラー。

...
Step 14 : COPY ./gitbook.sh /usr/bin/
 ---> Using cache
 ---> c181eddd121b
Step 15 : ENTRYPOINT gitbook.sh
 ---> Using cache
 ---> 2b12c9cb7f0a
Step 16 : VOLUME /tmp/_book
 ---> Using cache
 ---> c415ed222081
Successfully built c415ed222081
Starting 76a850829fcf_gitbookuml_viewer_1
Starting gitbookuml_compile_1

ERROR: for compile  Cannot start service compile: invalid header field value "oci runtime error: container_linux.go:247:
 starting container process caused \"exec: \\\"gitbook.sh\\\": executable file not found in $PATH\"\n"

ERROR: for viewer  Cannot start service viewer: invalid header field value "oci runtime error: container_linux.go:247: s
tarting container process caused \"exec: \\\"gitbook.sh\\\": executable file not found in $PATH\"\n"
ERROR: Encountered errors while bringing up the project.

またWindows固有の問題な気がするが、力尽きたので今日はここまで。

1
2
4

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
1
2