LoginSignup
8
2

The command 'docker' could not be found in this WSL 2 distro.

Posted at

事象 : Dockerがないといわれた

VisualStudioCodeからWSLにあるUbuntuでコンテナを起動しようとしたところ「Docker returned an error.」のメッセージが表示された。
ログを確認すると以下のメッセージが出力されていた。

The command 'docker' could not be found in this WSL 2 distro.
We recommend to 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 DesktopでUbuntuが有効になっていないから

  • 環境
    • Windows 11 Pro バージョン22H2
    • Docker Desktop v4.24.1

Docker Desktopの設定をみると[General]にある「Use the WSL 2 based engine」はONになっているのになぜ?
WSLも2になっているし・・・と思って再度設定を確認する。
[Resoures] > [WSL integration]でなんと「Ubuntu」がOFFになっていた。

$ wsl -l -v
  NAME                   STATE           VERSION
* docker-desktop-data    Running         2
  docker-desktop         Running         2
  Ubuntu                 Running         2

対応 : Ubuntuを有効にする

設定の[Resoures] > [WSL integration] > [Enable integration with additional distros:]の「Ubuntu」をONにして[Apply & restart]する
「distro」は「ディストリビューション(distribution)」のこと、というのをちゃんと覚えて次はメッセージですぐに気が付けるようにしたい。
image.png

8
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
8
2