icyfire
icyfire

Reputation: 1270

Connecting WSL VSCode extension to docker installed in Windows

I've installed Windows Subsystem for Linux (WSL) on my Windows 10 Pro machine. Following this tutorial, I set up docker on windows to work with WSL. In command-line of WSL, docker is working perfectly fine. I built multiple images and ran it in WSL.

I also have installed Microsoft Visual Studio Code inside WSL. I'm using it with the help of an X server for windows (VcXsrv). Inside VSCode, I have installed the docker extension. Even though I set the docker host correctly inside the settings, it's not connecting to Docker.

I know this is a twisted setup and I can use a proper Linux installation to make this work. But I need to know if it's possible to make it work in the current setup as it is important for me. Any help would be appreciated.

The exact error message thrown is:

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

My VSCode settings.json file:

{
    "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"
}

Output of docker info ran in WSL:

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

Upvotes: 4

Views: 3811

Answers (1)

zib
zib

Reputation: 101

This is strange: Details: connect ECONNREFUSED 127.0.0.1:80. The extension should not connect to 80 port. Do you remember setting this anywhere?

For now this combination works quite well:

  1. VSCode Insider Windows with Remote Development Extension https://aka.ms/vscode-remote/download/extension
  2. Docker for Windows
  3. Docker CE CLI on WSL

BTW that guide is a little bit outdated. You should follow the official guide to install docker-cli on Linux https://docs.docker.com/install/linux/docker-ce/ubuntu/ and follow this guide to setup VSCode https://code.visualstudio.com/docs/remote/containers.

On Linux you ONLY need to install docker-cliand don't need to do Post-installation steps for Linux.

Using VSCode Linux in WSL is not recommended anymore. But the Docker extension should also work out of box in VSCode on X servers.

By the end of the month the new VM-based WSL 2 with better compatibility will also come.

Upvotes: 2

Related Questions