はじめに
この記事は Windows 10 に WSL2 をインストールし、Docker Desktop を動かすまでの方法についてメモったものです。
手順の要約
- 管理者権限で PowerShell を起動し、WSL (既定OS:Ubuntu) をインストールします。
> wsl --install
- Windows 再起度後に任意のユーザ名とパスワードでアカウントを作ります。
Enter new UNIX username: [ユーザ名] (任意) New password: [パスワード] Retype new password: [パスワード] (確認用)
- Docker Desktop for Windows をインストールします。
- https://hub.docker.com/editions/community/docker-ce-desktop-windows/
- Docker Desktop Installer.exe をダウンロードして、インストーラの指示に従ってください。
- Docker Desktop が起動したら、設定から Docker Compose v2 を Enable にする。
- Windows 再起動する。
WSL インストール
公式サイトの手順の通りに実行します。
- 管理者権限で PowerShell を起動します。
- タスクバーの「ここに入力して検索」というところに、
powershell
と入れると、Windows PowerShell がヒットするので、その後に「管理者として実行する」という項目をクリックすると、管理者権限で PowerShell を起動できます。
- タスクバーの「ここに入力して検索」というところに、
- WSL をインストールします。
- プロンプトで、以下のようにインストールコマンドを実行します。
PS C:WINDOWS¥system32> wsl --install インストール中: 仮想マシン プラットフォーム 仮想マシン プラットフォーム はインストールされました。 インストール中: Linux 用 Windows サブシステム Linux 用 Windows サブシステム はインストールされました。 ダウンロード中: WSL カーネル インストール中: WSL カーネル WSL カーネル はインストールされました。 ダウンロード中: Ubuntu 要求された操作は正常に終了しました。変更を有効にするには、システムを再起動する必要があります。
- プロンプトで、以下のようにインストールコマンドを実行します。
- Windows を再起動します。
- Ubuntu がインストールされます。
- 再起動後、Ubuntu のインストールが始まります。
Installing, this may take a few minutes...
- ユーザを作成します。
Please create a default UNIX user account. The username does not need to match your Windows username. For more information visit: https://aka.ms/wslusers Enter new UNIX username: [ユーザ名] (任意) New password: [パスワード] Retype new password: [パスワード] (確認用)
- 以下のメッセージが表示されたらインストール成功です。
Installation successful! To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details. Welcome to Ubuntu 20.04 LTS (GNU/Linux 5.10.16.3-microsoft-standard-WSL2 x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage System information as of Wed Mar 30 22:08:41 JST 2022 System load: 0.0 Processes: 8 Usage of /: 0.4% of 250.98GB Users logged in: 0 Memory usage: 2% IPv4 address for eth0: 172.17.123.237 Swap usage: 0% 0 updates can be installed immediately. 0 of these updates are security updates. The list of available updates is more than a week old. To check for new updates run: sudo apt update This message is shown once once a day. To disable it please create the /home/ユーザ名/.hushlogin file.
- 再起動後、Ubuntu のインストールが始まります。
Docker Desktop のインストール
-
公式サイトから、Docker Desktop for Windows をインストールします。
-
"Download for Docker Desktop for Windows" の下にある "Docker Desktop for Windows" をクリックします。
-
"Docker Desktop Install.exe" がダウンロードされるので実行してください。
-
"Docker-Compose" を使う場合は、Docker Desktop の設定から "Docker-Compose v2" を使用するようにすると良いと思います。
-
最後に、Windows を再起動してあげると良いかなと思います。