将 WSL VSCode 扩展连接到安装在 Windows 中的 docker
Connecting WSL VSCode extension to docker installed in Windows
我已经在我的 Windows 10 Pro 机器上为 Linux (WSL) 安装了 Windows 子系统。按照 this 教程,我在 windows 上设置了 docker 以使用 WSL。在 WSL 的命令行中,docker 工作得很好。我在 WSL 中构建了多个图像并运行它。
我还在 WSL 中安装了 Microsoft Visual Studio 代码。我在 windows (VcXsrv) 的 X 服务器的帮助下使用它。在 VSCode 中,我安装了 docker 扩展。即使我在设置中正确设置了 docker 主机,它也没有连接到 Docker.
我知道这是一个扭曲的设置,我可以使用正确的 Linux 安装来完成它。但我需要知道是否有可能让它在当前设置中工作,因为它对我来说很重要。任何帮助将不胜感激。
抛出的确切错误信息是:
Unable to connect to Docker.
Please make sure you have installed Docker and that it is running.
Also, make sure you've followed the Linux post-install instructions:
"Manage Docker as a non-root user".
Details: connect ECONNREFUSED 127.0.0.1:80
我的VSCodesettings.json
文件:
{
"editor.fontFamily": "'Fira Code'",
"terminal.integrated.shell.linux": "/bin/zsh",
"terminal.integrated.fontFamily": "monospace",
"editor.fontLigatures": true,
"terminal.integrated.fontWeightBold": "normal",
"editor.fontWeight": "500",
"python.venvPath": "/home/r2m/Work/venv",
"terminal.integrated.rendererType": "dom",
"git.autofetch": true,
"workbench.colorTheme": "Material Theme Darker High Contrast",
"docker.host": "tcp://localhost:2375"
}
WSL docker info
运行 的输出:
Containers: 2
Running: 0
Paused: 0
Stopped: 2
Images: 16
Server Version: 18.09.2
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9754871865f7fe2f4e74d43e2fc7ccd237edcbce
runc version: 09c8266bf2fcf9519a651b04ae54c967b9ab86ec
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.125-linuxkit
Operating System: Docker for Windows
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934GiB
Name: linuxkit-00155d028201
ID: PBQD:BCLL:MYXY:6OFR:KJB2:UK46:VQWG:ELYT:6NGO:42QP:4SRK:FHO2
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 22
Goroutines: 47
System Time: 2019-03-27T22:09:33.2435878Z
EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine
这很奇怪:Details: connect ECONNREFUSED 127.0.0.1:80
。分机不应连接到 80 端口。您还记得在任何地方设置这个吗?
目前这个组合效果很好:
- VSCode 内部人员 Windows 具有远程开发扩展 https://aka.ms/vscode-remote/download/extension
- Docker 对于 Windows
- Docker WSL 上的 CE CLI
顺便说一句,该指南有点过时了。您应该按照官方指南在 Linux https://docs.docker.com/install/linux/docker-ce/ubuntu/ and follow this guide to setup VSCode https://code.visualstudio.com/docs/remote/containers.
上安装 docker-cli
在 Linux 上,您 仅 需要安装 docker-cli
而不需要安装 Post-installation steps for Linux
.
不再推荐在 WSL 中使用 VSCode Linux。但是 Docker 扩展也应该在 X 服务器上的 VSCode 中开箱即用。
到月底,兼容性更好的新VM-based WSL 2也会到来。
我已经在我的 Windows 10 Pro 机器上为 Linux (WSL) 安装了 Windows 子系统。按照 this 教程,我在 windows 上设置了 docker 以使用 WSL。在 WSL 的命令行中,docker 工作得很好。我在 WSL 中构建了多个图像并运行它。
我还在 WSL 中安装了 Microsoft Visual Studio 代码。我在 windows (VcXsrv) 的 X 服务器的帮助下使用它。在 VSCode 中,我安装了 docker 扩展。即使我在设置中正确设置了 docker 主机,它也没有连接到 Docker.
我知道这是一个扭曲的设置,我可以使用正确的 Linux 安装来完成它。但我需要知道是否有可能让它在当前设置中工作,因为它对我来说很重要。任何帮助将不胜感激。
抛出的确切错误信息是:
Unable to connect to Docker.
Please make sure you have installed Docker and that it is running.
Also, make sure you've followed the Linux post-install instructions:
"Manage Docker as a non-root user".
Details: connect ECONNREFUSED 127.0.0.1:80
我的VSCodesettings.json
文件:
{
"editor.fontFamily": "'Fira Code'",
"terminal.integrated.shell.linux": "/bin/zsh",
"terminal.integrated.fontFamily": "monospace",
"editor.fontLigatures": true,
"terminal.integrated.fontWeightBold": "normal",
"editor.fontWeight": "500",
"python.venvPath": "/home/r2m/Work/venv",
"terminal.integrated.rendererType": "dom",
"git.autofetch": true,
"workbench.colorTheme": "Material Theme Darker High Contrast",
"docker.host": "tcp://localhost:2375"
}
WSL docker info
运行 的输出:
Containers: 2
Running: 0
Paused: 0
Stopped: 2
Images: 16
Server Version: 18.09.2
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9754871865f7fe2f4e74d43e2fc7ccd237edcbce
runc version: 09c8266bf2fcf9519a651b04ae54c967b9ab86ec
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.125-linuxkit
Operating System: Docker for Windows
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934GiB
Name: linuxkit-00155d028201
ID: PBQD:BCLL:MYXY:6OFR:KJB2:UK46:VQWG:ELYT:6NGO:42QP:4SRK:FHO2
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 22
Goroutines: 47
System Time: 2019-03-27T22:09:33.2435878Z
EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine
这很奇怪:Details: connect ECONNREFUSED 127.0.0.1:80
。分机不应连接到 80 端口。您还记得在任何地方设置这个吗?
目前这个组合效果很好:
- VSCode 内部人员 Windows 具有远程开发扩展 https://aka.ms/vscode-remote/download/extension
- Docker 对于 Windows
- Docker WSL 上的 CE CLI
顺便说一句,该指南有点过时了。您应该按照官方指南在 Linux https://docs.docker.com/install/linux/docker-ce/ubuntu/ and follow this guide to setup VSCode https://code.visualstudio.com/docs/remote/containers.
上安装 docker-cli在 Linux 上,您 仅 需要安装 docker-cli
而不需要安装 Post-installation steps for Linux
.
不再推荐在 WSL 中使用 VSCode Linux。但是 Docker 扩展也应该在 X 服务器上的 VSCode 中开箱即用。
到月底,兼容性更好的新VM-based WSL 2也会到来。