LoginSignup
7
2

More than 3 years have passed since last update.

Surface GoでDockerを動かすまでの道のり

Last updated at Posted at 2020-03-07

Docker Desktop for Windowsの最新プレビュー版 から、Home版Windows10でもDocker Desktopが利用可能になった。
手持ちのSurface Goでもコンテナを動かすことが可能になった訳だが、Surface GoはWindows10の「Sモード」が有効化されていること、WSL2の利用にInsider Preview版ビルドが必要なことから、いくらか余計な手順が必要となる。
以下に簡単に手順を記しておく。

注意

  • Docker及びWindowsのPreview版利用は自己責任で
  • 2020/03現在の情報であるため、最新情報をチェックの上で実施すること

Sモードの解除

Surface Goは、購入時点ではWindows10の「Sモード」が有効化されており、Microsoft Store以外からアプリケーションをインストールすることができない。
Docker Desktopのインストールに先立って、Sモードを解除する必要がある。

手順は 公式のFAQに書かれている通りだが、抜粋すると以下の通り。

  1. [設定] 、[更新とセキュリティ] 、[ライセンス認証] を開く
  2. [Windows 10 Home に切り替える] セクションを見つけて、[Microsoft Store に移動] リンクを選択する
  3. Microsoft Store に表示されるページ ([S モードの解除] または同様のページ) で、[入手] ボタンを選択

この際、Microsoftアカウントでの認証が必要となるため、Windowsをローカルアカウントで運用している場合は別途アカウントを用意しておくこと。

エディションが以下のように表記されていれば、無事にSモードが解除されている。
image.png

Insider Preview版ビルドのインストール

Windows10の最新安定版である1909 (November 2019 Update) はまだWSL2に対応していないため、先行版ビルドにアップグレードする必要がある。
以下の手順でInsider Previewプログラムに参加し、先行版ビルドへアップグレードする。

  1. [設定]、[更新とセキュリティ]、[Windows Insider Program]を開く
  2. [開始する]を選択し、Microsoftアカウントをリンク
  3. 任意の「リング」を選択する (WSL2を利用したいだけの場合は、「スロー」でよい)
  4. 再起動してWindows Updateを実行

以下のように、OSビルド番号が 19040 以上になっていればよい。
image.png

WSL2の有効化

続いて、Dockerの実行環境となるWSL2を有効化する。

正式な手順は 公式ドキュメント に記されているが、Docker Desktopを利用したいだけの場合、以下のコマンドをPower Shellで実行し再起動すればよい。

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

ここまでの手順を踏んで、ようやくDocker Desktopをインストールするための前準備が完了。

Docker Desktopのインストール

Docker Desktop公式サイトからPreview版(Docker Desktop Edge)のインストーラーをダウンロードし、実行する。
この際、WSL2対応を有効化するか聞かれるため、忘れずチェックを入れておく。

動作確認

Hello Worldを実行し動作確認。

> docker run --rm 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/get-started/

ちなみに、Docker Desktopの実行環境は、WSL上のディストリビューションとして構成されている様子。
wsl -l コマンドでインストールされているディストリビューションを確認すると、Docker Desktop関連のものが自動的に追加されていることがわかる。

> wsl -l -v
  NAME                   STATE           VERSION
* Ubuntu-18.04           Running         2
  docker-desktop         Running         2
  docker-desktop-data    Running         2
```https://docs.microsoft.com/ja-jp/windows/wsl/wsl2-install
7
2
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
7
2