LoginSignup
1
1

More than 3 years have passed since last update.

Dockerを知らない素人がWindows10 homeでDocker-Toolboxを使ってDockerコンテナをRunするまでのお話。

Last updated at Posted at 2020-04-30

前提条件

  • Dockerについて何も知らない社会人2年目の社員。
  • 上司から「Docker使うから今のうちに勉強しといて」とさっき言われた。。。
  • 備忘録とモチベ維持のため、Qiitaでアウトプットしつつ勉強を進める予定。

環境

  • 10万ちょいで買った4年目のNEC LAVIE(ノートPC)
    • Intel(R) Core(TM) i5-7Y54 CPU@ 1.20GHz 1.60GHz
    • RAM:8GB
    • Windows10 home 64bit
    • 最近起動が遅いのが悩み。(ログイン画面の表示が遅い) PC性能.png

Dockerとはなんぞや。。。

→コンテナ型の仮想環境を作ること!

仮想環境は、Anacondaで言うとBaseと異なる環境が作れる機能だから、PCベースで言うとPCの内側に別のPCが走ってるイメージ。内側のPCは外側のPCに影響されにくいからどんなPCに乗っけても動いてくれる頼りになるやつなんですね。

コンテナ型というのは、従来の仮想化と比べて良いという理解。従来の仮想化ではOSも含めて仮想化を行ってたけど、ファイル重い(OS分容量必要)し、起動遅いし(OSをたくさん起動するから)で扱いずらかった。これをマシーンリソースがかかるとかオーバーヘッドが生じるとかいう専門用語があるわけです。

コンテナ型は元のOSに乗せられるからファイル数軽いし、起動も早い。開発においては便利なツールなんですね。

従来の仮想化とDocker.png

従来でも元のOSを「ホストOS」、仮想側を「ゲストOS」なんて呼び分けてるけど、これはDockerでも同じなので覚えておいた方がいい(マウントの設定だったりで混乱する)

ただOSが減る分、元のPCから影響受けたりセキュリティ対策対策もちゃんとしないとだから、いいこと尽くめというわけでもないのは注意が必要ですね。

Docker環境構築するよ!

Dockerにも種類がある!

  • Docker Community Edition(Docker CE)

    • 無償版のDocker
    • とはいえ問題なく使える
      • Stable版…四半期ごとのリリース。安定したものが使える
      • Edge版…月1回のリリース。最新版を使える。
  • Docker Enterprise Edition(Docker EE)

    • 有償版Docker
    • Docker社認定のコンテナ・プラグインが使える
    • イメージのセキュリティあり
    • プライベートリポジトリあり

まぁ自主勉強ならDocker CEのStable版が良さそう。

さあインストールするよ!

インストールと言っても3種類くらいあるので個々人の環境によって選ぼう!
1. Docker for Windows
2. Docker for Mac
3. Docker Toolbox

1つ目のはWindowsじゃんやった~インストールしよっと思ったのもつかの間、これは「Windows 10 Pro」しか使えないので注意!しかもハイパーバイザーの設定も必要。出だしから難易度高いなぁ。Docker for Windows 10 Proって改名してもらいたい

2つ目のはMac用らしい...(筆者はマックのこと知らない)

3つ目のは我らがwindows 10 homeでも使えるやつ!早速インストール♪
https://github.com/docker/toolbox/releases
image.png

↑GitHubからインストール
このレガシーな雰囲気プンプンな香りに負けること無かれ。
インストール.png

↑見慣れた.exeインストーラー
インストールしていきますよ~

不明な発行元を「はい」して、デフォルトもまま突き進めばおk!
image.png
↑Docker Quickstart Terminalのショートカットをクリックして実行!
初回起動には時間がかかる。

image.png

↑これで準備完了!クジラのマークが目印!

Dockerを操作するよ!

まぁまずはversionを観察!
$ docker version
version情報の一覧が出てきます↓

$ docker version                                                                                                        Client:
 Version:           19.03.1
 API version:       1.40
 Go version:        go1.12.7
 Git commit:        74b1e89e8a
 Built:             Wed Jul 31 15:18:18 2019
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.5
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.12
  Git commit:       633a0ea838
  Built:            Wed Nov 13 07:28:45 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.10
  GitCommit:        b34a5c8af56e510852c35414db4c1f4fa6172339
 runc:
  Version:          1.0.0-rc8+dev
  GitCommit:        3e425f80a8c931f88e6d94a8c831b9d5aa481657
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

なにはともあれHello World!

docker run hello-world

hello-worldというコンテナが立ち上がります!

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete                                                                                             Digest: sha256:8e3114318a995a1ee497790535e7b88365222a21771ae7e53687ad76563e8e76
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/

Hello from Docker!

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