Docker ToolboxをWindows10 homeにインストールする方法

侍エンジニア塾

侍エンジニア塾でプログラミングの学習中です。その中で開発環境を構築するフェーズに入ってきました。

Laravelの開発環境をローカルPCに作ることになりました。

それでLaradockというのをインストールすることに。
しかしLaradockの前段階でDockerというのをインストールする必要がある、ということです。

さて、Dockerの公式サイトへ行ってみました。

最近のプログラマーはMacOSを使っているので自然とMac向けのページが増えてきてしょんぼりしています。

Get started with Docker for Windowsのページを探し当てました。
https://docs.docker.com/docker-for-windows/

インストールとダウンロードのページがこちら。
https://docs.docker.com/docker-for-windows/install/

と、その前にDockerの会員登録とログインが必要のようです。

Dockerへの会員登録

①「Please Login To Download」をクリック

②画面下部の「Create Account」をクリック

③必要事項を入力しチェックを入れSign UPをクリック

④認証メールが届くので「Confirm Your Email」

⑤「Get Docker」をクリックしてダウンロード

Dockerのインストールでエラー

ダウンロードファイルを起動してインストール・・・

ぎゃー。

Installation failed: one pre-requisite is not fullfilled
Docker for Windows requires Windows 10 Pro oe Enterprize version

と書いてあるので、自分のマシンはWindows 10 Homeなのでインストールできないみたい。

Windows 10 HomeでもインストールできるDockerが無いか探すか、
Windows 10 Proへアップグレード(約1万5千円)するか検討。

Docker ToolboxでWindows 10 Homeにインストール

Windows 10 Homeなど要件を満たしていないPC向けに公式からDocker Toolboxというのが出ている様子。

https://docs.docker.com/toolbox/overview/

けど、公式からもOS要件を満たしてDocker for Windowsをインストールすることが勧められています。

Windows 10 Proだとハイパーバイザー型で仮想化が出来るMicrosoft Hyper-Vというのが使えて、その上でDockerが動く様子です。

けどWindows 10 HomeにはHyper-Vが無いのでホストOS型でやる、という事なんだと思います。Docker Toolboxの中にOracle VirtualBoxが入ってて、同時にインストールされるのでこの上で動くんだと予想。

あとGit for Windowsというのも入っている。

Docker Toolboxをダウンロードしておきます。

Docker Toolboxをインストール

Overview of Docker Desktop
Explore more of Docker Desktop, what it has to offer, and its key features. Take the next step by downloading or find additional resources.

ハードウェア仮想化有効の確認

まずHardware Virtualization Technologyをサポートしているか、有効になっているか確認。

上記ページの中ほどにあるリンクからSpeccyというツールをダウンロードしてインストール。
CPU情報を確認。

VirtualizationがSupported, Enabledになっているので大丈夫だと思う。

Docker Toolboxをインストール

基本的には画面の指示に従って進めていけばOK。

過去にVirtualBoxをインストールしてあるPCの場合は、Docker ToolboxによるVirtualBoxのインストールはしてはいけないので、途中のチェックを外す必要がある様子。

そうでなければ特にチェックを入れたり外すことなく進めていきました。

途中でWindowsの画面が暗転して「プログラムによる変更を許可しますか」みたいな画面が出てきたら「はい」をクリックします。(何度か出る)

インストールが完了しました。

デスクトップに以下3つのアイコンが出ました。

・Oracle VM VirtualBox
・Kitematic(Alpha)
・Docker Quickstart Terminal

Docker Quickstart Terminalを起動

起動時に
.docker\machine\machines\default\config.json: The system cannot find the file specified.
Looks like something went wrong in step Checking status on default … Press any key to continue…

というメッセージが出てどうやら失敗することもありました。
いちどコントロールパネルから今回インストールされたDocker ToolboxやOracle VirtualBoxをアンインストールしてPC再起動したら大丈夫になったことがあります。

基本的にはDocker Quickstart Terminalを起動すれば自動的に始まるようです。

クジラが出てきたらOK。

docker run hello-worldを入力

ターミナルに$マークのプロンプトが出てきたら、コマンドを入力します。

docker run hello-world

で、次のような出力がでれば成功しているとのこと。

$ docker run hello-world
Unable to find image ‘hello-world:latest’ locally
Pulling repository hello-world
91c95931e552: Download complete
a8219747be10: Download complete
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 Engine CLI client contacted the Docker Engine daemon.
2. The Docker Engine daemon pulled the “hello-world” image from the Docker Hub.
(Assuming it was not already locally available.)
3. The Docker Engine daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker Engine daemon streamed that output to the Docker Engine CLI 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:
https://docs.docker.com/userguide/

たぶん成功した。

コマンドを入力してみる

バージョン情報出力

$ docker --version
Docker version 18.03.0-ce, build 0520e24302

インストール情報の詳細

$ docker info
Containers: 1
 Running: 0
 Paused: 0
 Stopped: 1
Images: 1
Server Version: 18.09.0
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.14.79-boot2docker
Operating System: Boot2Docker 18.09.0 (TCL 8.2.1)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 989.4MiB
Name: default
ID: ZMEJ:EEY3:APUP:IGRW:3LXY:UESN:CYP2:YGVJ:SHXH:7DGI:7PHW:BVBC
Docker Root Dir: /mnt/sda1/var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
No Proxy: 192.168.99.100
Registry: https://index.docker.io/v1/
Labels:
 provider=virtualbox
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

ダウンロードしたDockerイメージの一覧
先ほどhello-worldのダウンロードが出来てれば以下のように出る。

$ docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              4ab4c602aa5e        3 months ago        1.84kB

コンテナの一覧を表示

$ docker container ls --all
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                         PORTS               NAMES
a01eeffbe274        hello-world         "/hello"            About an hour ago   Exited (0) About an hour ago                       stupefied_edison

一通りこれでDocker Toolboxのインストールが完了した・・・のか?

Docker Toolboxでファイル共有

サーバーの仮想化とか、Dockerのインストール関連のときに「ファイル共有」という言葉がよく出てくるけど、詳しく解説してるのがなくて意味がわからなかったけどやっとわかった。

これはWindowsのドライブの中にあるファイル(エクセルファイルとかテキストファイルとか)に、Docker側からアクセスする、という意味。

Docker Toolboxでは、WindowsのC:\Usersへのアクセス権をデフォルトで持っています。

/c/Users

でアクセスできる。cは小文字で、UsersのUは大文字。

cd /c/Usersでアクセスできた。

で、これ以外のディレクトリへはアクセス権が無いので他の場所にプロジェクトを作りたいとかアクセスしたい場合はVirtualBox UIを使ってマウント、ということをやればよいとのこと。

自分は/uc/Users/で作業するのでファイル共有の作業は不要でした。

ここまででDocker Toolboxのインストールが完了。

DockerをWindows10 Homeにインストールする、のまとめ

Docker for WindowsはWindows 10 ProかEnterprizes版じゃないとインストールできない。
Windows 10 ProではHyper-Vが動いているので、そのうえでDockerを動かすことが出来る。

Windows 10 HomeにはHyper-Vが動いていないのでDocker Toolboxというので代用。
(公式にはProへアップグレードが推奨)

Docker ToolboxはWindows 10 Homeにインストールできる。Oracle VirtualBoxやGit for Windowsが同時にインストールされる。

ということで今日は以上です。

タイトルとURLをコピーしました