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

Source: StackOverflow

LEAVE A COMMENT