Motomichi Works Blog

モトミチワークスブログです。その日学習したことについて書いている日記みたいなものです。

Windows 10 Homeでdocker入門 Hello Worldまでやってみる | Windows 10 Home + WSL + Ubuntu 16.04 でdocker その0001

参考にさせて頂いたページ

今日の環境

  • Windows10 Home
  • WSL + Ubuntu 16.04

はじめに

2018年09月08日現在で、WSLではコンテナ内に入れなくて解決できないので諦めてvagrantのcentos7.3にdocker-ceをインストール試しています。

ポイント

  • Windows10 Homeでもdockerが使えるようになりました。
  • 2018年09月07日現在ではUbuntu 16.04をインストールすると良いようです。
  • 2018年09月07日現在ではUbuntu 16.04を管理者として実行する必要があります。
  • 2018年09月07日現在ではこの記事の通りでしたが、なるべく新しい情報を探した方が良いです。

WSLの有効化とUbuntu 16.04のインストール

以下の記事を書きました。

今回は Ubuntuのバージョンは16.04をインストールすることに注意してください。

Ubuntu 16.04を管理者として実行する

Ubuntu 16.04を右クリックして、管理者として実行します。

f:id:motomichi_works:20180908003605p:plain

dockerをインストールして起動する

参考にさせて頂いているページの「Dockerのセットアップ」の項目そのままですが、以下のコマンドを実行しました。

$ sudo apt update
$ sudo apt upgrade -y
$ sudo apt install docker.io
$ sudo cgroupfs-mount
$ sudo usermod -aG docker $USER
$ sudo service docker start

一度Ubuntuを終了する

一度終了します。 これ重要みたいです。

$ exit

Ubuntu 16.04をもう一度管理者として実行する

Ubuntu 16.04を右クリックして、もう一度管理者として実行します。

dockerを起動する

以下のコマンドでdockerを起動します。

$ sudo cgroupfs-mount && sudo service docker start

dockerの状態を確認する

ここは sudo いりません。

以下のコマンドでdockerが起動状態か確認します。

$ service docker status

以下のように表示されたら上手くいっています。

* Docker is running

dockerでHello World

dockerが動くか確認します。

dockerのイメージをpullしてhello worldをやってみます。

ここも sudo いりません。

docker run hello-world

以下のように表示されたらうまく動いています。

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

dockerを使ってみる

次の記事でdockerの基本操作について書きました。

Windows 10 Homeでdocker入門 Hello Worldの次の段階をやってみる | Windows 10 Home + WSL + Ubuntu 16.04 でdocker その0002 - Motomichi Works Blog