WSL 環境セットアップ

以下の手順に従って、Windows に WSL 環境をセットアップします。

  1. Ubuntu のインストール

    Docker Engine をインストールする環境として、WSL(Windows Subsystem for Linux)上に Ubuntu 24.04 をインストールします。公式参考ページはこちらです。
    PowerShell 又は Command Prompt を管理者で実行し、以下のコマンドでインストールを行います。

    wsl --install -d Ubuntu-24.04
    
    下記のように出力されれば成功です。
     ダウンロード中: Ubuntu 24.04 LTS
     インストール中: Ubuntu 24.04 LTS
     ディストリビューションが正常にインストールされました。'wsl.exe -d Ubuntu-24.04' を使用して起動できます
    
    

    注意: 初回 WSL をインストールされた場合、Windows を再起動する必要があります。再起動後再度 PowerShell 又は Command Prompt で上記のコマンドを実行してください。

    操作画面イメージ

  2. ユーザ情報の設定

    以下のコマンドを実行して Ubuntu を起動します。

    wsl.exe -d Ubuntu-24.04
    

    Ubuntu のユーザID とパスワードを聞かれますので入力します。

    今回のユーザID はappuserとします。

    Provisioning the new WSL instance Ubuntu-24.04
    This might take a while...
    Create a default Unix user account: appuser
    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.
    
    Welcome to Ubuntu 24.04.1 LTS (GNU/Linux 5.15.167.4-microsoft-standard-WSL2 x86_64)
    
    * Documentation:  https://help.ubuntu.com
    * Management:     https://landscape.canonical.com
    * Support:        https://ubuntu.com/pro
    
    System information as of Sat Feb  8 10:35:49 UTC 2025
    
    System load:  0.4                 Processes:             31
    Usage of /:   0.1% of 1006.85GB   Users logged in:       0
    Memory usage: 4%                  IPv4 address for eth0: 172.31.207.129
    Swap usage:   0%
    
    
    This message is shown once a day. To disable it please create the
    /home/appuser/.hushlogin file.
    
  3. Ubuntu を起動

    Windows のアプリから「Ubuntu-24.04」を探して起動します。

    下記のように出力されれば成功です。
    To run a command as administrator (user "root"), use "sudo <command>".
    See "man sudo_root" for details.
    
    appuser@XXXXXXXX:~$