0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Docker】VSCodeでDev Containersを利用してDockerのデーモンに接続できないエラーの対処法(WSL,Ubuntu)

Posted at

はじめに

VSCodeの拡張機能であるDev Containersを利用してCtrl+Shift+PからReopen in Containerを選択することで、VSCodeを用いてdocker container上での開発が可能になります。
しかし、デーモンに接続できませんというエラーの表示がたまに見られます。ログを見てみると、具体的には以下のようなエラーが表示されています。

[82697 ms] Start: Run in Host: docker version --format {{json .}}
[82710 ms] {"Client":{"Version":"27.3.1","ApiVersion":"1.47","DefaultAPIVersion":"1.47","GitCommit":"ce12230","GoVersion":"go1.22.7","Os":"linux","Arch":"amd64","BuildTime":"Fri Sep 20 11:39:44 2024","Context":"default"},"Server":null}
[82710 ms] Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

[82712 ms] Exit code 1

このエラーの対処法について説明します。環境はWSLUbuntuで、Docker Desktopの使用を前提としますが、Rancher Desktopなどでも同様にして対処が可能です。

エラーの対処

原因は、Docker DesktopWSL integrationUbuntuが有効になってないことです。

Docker Desktopを起動し、右上の歯車マークからSettingを開いてください。
ResourcesWSL integrationを選択し、Enable integration with additional distrosUbuntuを有効にしてください。

最後に、忘れずに右下のApply & restartを選択して保存してください。

スクリーンショット 2025-01-13 165422.png

Rancher Desktopなどを使っている場合も同様に、WSLUbuntuを有効にする設定があると思うので探して有効にしてください。

再度VSCodeからReopen in Containerを選択してみると、無事開発コンテナーに入れると思います。

もしまだエラーが出るようであれば、Dockerのバージョンアップや再インストールなど試してみてください。

参考

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?