You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用VSCode Dev Containers与Rootless Docker时无法连接Docker守护进程求助

求助:VS Code Dev Containers 搭配无根Docker时连接Docker守护进程失败

遇到的错误:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

VS Code错误输出截图:
VS Code中Dev Containers扩展的错误提示

环境信息

  • Ubuntu 22.04.3 LTS
  • Visual Studio Code 1.85.1
  • Docker Engine Community 24.0.7

已尝试的解决方法

  • 在/etc/profile.d/my_env_vars.sh中设置DOCKER_HOST环境变量(设置后已重新登录):export DOCKER_HOST=unix:///run/user/1000/docker.sock
  • 创建指向/run/user/1000/docker.sock的符号链接:ln -s /run/user/1000/docker.sock /var/run/docker.sock
  • 安装VS Code Docker扩展后,将DOCKER_HOST变量设置为:unix:///run/user/1000/docker.sock
  • 验证Docker可正常运行:执行docker run hello-world,输出如下:

    Hello from Docker!
    This message shows that your installation appears to be working correctly.

    To generate this message, Docker took the following steps:

    1. The Docker client contacted the Docker daemon.
    2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64)
    3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading.
    4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.
  • 验证活动上下文:执行docker context ls,结果截图:
    Docker上下文列表截图

感谢您的帮助。

内容的提问来源于stack exchange,提问作者fire_water

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 16:05:08