Windows 10 home に WSL2 と DockerDesktop をインストールして、Docker の環境を構築してみたので、その時の手順を残します。
1. 環境
項目 | 詳細 |
---|---|
CPU | Intel(R) Core(TM) i3-8130U CPU @ 2.20GHz 2.21 GHz |
メモリ | 8.00 GB |
グラフィックス カード | Intel(R) UHD Graphics 620 (128 MB) |
OS | Windows 10 Home バージョン 2009(OSビルド 19045.5854) |
2. WSL2 のインストール
2.1. Windows PowerShellを起動
Windowsのスタートメニューから「Windows PowerShell」ー「Windows PowerShell」を右クリックし管理者で実行します。
2.2. WSL2をインストール(wsl --install
)
Windows PowerShell で以下のコマンドを実行します。
wsl --install
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
新しいクロスプラットフォームの PowerShell をお試しください https://aka.ms/pscore6
PS C:\WINDOWS\system32> wsl --install
以下のようにインストールが開始されるので、終了するまで待ちます。
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
新しいクロスプラットフォームの PowerShell をお試しください https://aka.ms/pscore6
PS C:\WINDOWS\system32> wsl --install
インストール中: 仮想マシン プラットフォーム
仮想マシン プラットフォーム はインストールされました。
インストール中: Linux 用 Windows サブシステム
Linux 用 Windows サブシステム はインストールされました。
インストール中: Linux 用 Windows サブシステム
Linux 用 Windows サブシステム はインストールされました。
インストール中: Ubuntu
Ubuntu はインストールされました。
要求された操作は正常に終了しました。変更を有効にするには、システムを再起動する必要があります。
PS C:\WINDOWS\system32>
2.3. Windows再起動
Windowsを再起動します。
2.4. Ubuntuのユーザ、パスワード設定
Windowsの再起動後、Ubuntuのインストールが実行されます。
インストール完了後、Ubuntuのユーザ、パスワードがきかれるので設定します。
ここではtest_user
のユーザーを入力しています。
ダウンロードしています: Ubuntu
インストールしています: Ubuntu
ディストリビューションが正常にインストールされました。'wsl.exe -d Ubuntu' を使用して起動できます
Ubuntu を起動しています...
Provisioning the new WSL instance Ubuntu
This might take a while...
Create a default Unix user account: test_user
New password:
Retype new password:
passwd: password updated successfully
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
test_user@hostname:/mnt/c/WINDOWS/system32$
3. DockerDesktop のインストール
3.1. DockerDesktopのインストーラーのダウンロード
「Docker 公式ページ」を開き、Docker Desktop Installer.exe
をダウンロードします。
3.2. DockerDesktopのインストーラーを実行
Docker Desktop Installer.exe
を実行します。
以下の画面で「OK」をクリックします。
インストールが開始されるのでしばらく待ちます。
「Close and log out」をクリックします。
3.3. Windowsの再起動
Windowsを再起動します。
3.4. Dcokerの設定
Windows再起動後、Dockerの同意が求められるので、「Accept」をクリックします。
メールアドレスを聞かれますが、「Skip」をクリックします。
役割を聞かれますが、「Skip」をクリックします。
右上の設定(歯車アイコン)をクリックします。
「Resources」をクリックします。
「Resources」-「WSL integration」をクリックします。
「Enable integration with my default WSL distro」にチェックが付いていることを確認し、「Ubuntu」をチェックして、「Apply & restart」をクリックします。
4. Docker の動作確認
4.1. Ubuntu 起動
Windowsのスタートメニューから「Ubuntu」を選択します。
4.2. Docker のバージョン確認
Ubuntuで以下のコマンドで、インストールされたdockerのバージョンを確認します。
docker --version
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
test_user@hostname:~$ docker --version
Docker version 28.1.1, build 4eba377
test_user@hostname:~$
4.3. hello-world の実行
Ubuntuで以下のコマンドで、docker の hello-world を実行します。
docker run hello-world
以下のメッセージが表示されると成功です。
Hello from Docker!
This message shows that your installation appears to be working correctly.
test_user@hostname:~$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
e6590344b1a5: Pull complete
Digest: sha256:940c619fbd418f9b2b1b63e25d8861f9cc1b46e3fc8b018ccfe8b78f19b8cc4f
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/
test_user@hostname:~$
以上