技術ネタを中心に、できるだけ自分から発信していくためのブログ。 いつか誰かの役に立ちますように。

Docker on Windows 10 (1) Dockerインストール

 以下の記事を参考に、Windows 10 x64にDockerをインストールして、ちょっと遊んでみました。

www.atmarkit.co.jp

qiita.com

なぜDocker?

  • Webアプリケーション(具体的にはAirsonic)をちょっと試したいときに、VPSNASやを用意するのは大変
  • CygwinWindows Subsystem for Linux (WSL) は、インストール後の環境メンテが大変
  • 前からDockerによる仮想化に興味があったが、触れていなかった

本記事でやること

  • Docker for Windows Community Edition (Docker CE) のインストール
  • Kitematic のインストール

PCスペック

設定

  • BIOSから、Hyper-Vを有効化
  • コントロールパネル → プログラムと機能 → Windowsの機能の有効化または無効化
    • Hyper-V全てにチェックを入れる
  • PC再起動
  • 以下URLから、Docker for Windows Community Edition (Docker CE) をダウンロード
    • ユーザー登録を求められるので、適当なID/Pass (以降Docker ID/Pass) を登録しておく hub.docker.com
  • 指示に従ってインストール
  • インストール後に右下に出てくるポップアップにはDocker ID/Passを入力しておく

動作テスト

> docker -v
Docker version 18.09.2, build 6247962

> docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Already exists ※一旦イメージを削除して再度runしたため
Digest: sha256:92695bc579f31df7a63da6922075d0666e565ceccad16b59c3374d2cf4e8e50e
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.
    (amd64)
 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 ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/
  • 上記 docker run が動けば、以下3つが確認されたことになる。
    • dockerが正常にインストールされたこと
    • dockerがインターネットに接続でき、イメージをpullできること
    • docker上でコンテナを作成し、コンテナが動作できること

Kitematicのインストール

  • コンテナをGUIで操作できるツール、コマンドプロンプトに慣れていないなら入れておきたい

  • タスクトレイのDockerアイコンを右クリック → Kitematic を選択すると、ダウンロードするか確認するダイアログが出る

  • URL先に飛び、Kitematicをダウンロード
  • Dockerのインストール先パスの下に Kitematic フォルダを作り、その直下にKitematic.exeなどが配置されるように展開
    • C:\Program Files\Docker\Kitematic に置く
    • C:\Program Files\Docker\Docker\Kitematic ではない
  • タスクトレイのDockerアイコンを右クリック → Kitematicを選択
  • Docker ID/Passを入力

参考

  • 会社で認証プロキシみたいなプロキシを通るときは、タスクアイコン右クリック → Settings → Proxiesに、以下の記法でID/Passを指定すると上手く通ってpull/pushできる場合がある
    • パスワードべた書きなので要注意
http://[ID]:[Pass]@[Domain]:[port]

例
http://hogehoge:hugahuga (@) example.com:8080
※ 実際にはスペースや[]()無しで書くこと