使用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错误输出截图:
环境信息
- 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:
- The Docker client contacted the Docker daemon.
- The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64)
- The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading.
- The Docker daemon streamed that output to the Docker client, which sent it to your terminal.
- 验证活动上下文:执行
docker context ls,结果截图:
感谢您的帮助。
内容的提问来源于stack exchange,提问作者fire_water
相关产品推荐
相关产品推荐

