🥶
WSL上でDockerが動かない
問題
DockerコマンドがWSL上のUbuntuではじかれる
環境
OS Name: Microsoft Windows 11 Pro Insider Preview
OS Version: 10.0.22523 N/A Build 22523
OS Manufacturer: Microsoft Corporation
OS Configuration: Standalone Workstation
OS Build Type: Multiprocessor Free
状態
$ docker
The command 'docker' could not be found in this WSL 1 distro.
We recommend to convert this distro to WSL 2 and activate
the WSL integration in Docker Desktop settings.
For details about using Docker Desktop with WSL 2, visit:
https://docs.docker.com/go/wsl2/
dockerコマンドを実行すると弾かれ、エラーメッセージが出る
内容としては
docker
コマンドはWSL 1のディストロでは見つかりませんでした
このディストロをWSL 2に変換し、Docker Desktopの設定でWSL統合を有効化することをお勧めします。
WSL 2でDocker Desktopを使用する場合の詳細については、以下を参照してください。
https://docs.docker.com/go/wsl2/
まぁ、書かれてる通りWSL 1 だとダメでWSL 2にしないといけません。
一応確認すると
>wsl -l -v
NAME STATE VERSION
* Ubuntu Converting 1
docker-desktop Running 2
docker-desktop-data Running 2
案の定WSL1でした。
解決方法
というわけでアップデートします(5分程度かかります)
>wsl --set-version Ubuntu 2
Conversion in progress, this may take a few minutes...
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
Conversion complete.
その後デフォルトバージョンも上げておきます
>wsl --set-default-version 2
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
The operation completed successfully.
無事解決しました。
$ docker -v
Docker version 20.10.10, build b485636
Discussion