for-win icon indicating copy to clipboard operation
for-win copied to clipboard

Can't start Docker Engine on wsl2

Open Cayincc opened this issue 9 months ago • 12 comments

Description

WSL version:

WSL version: 2.5.1.0
Kernel version: 6.6.75.1-1
WSLg version: 1.0.66
MSRDC version: 1.2.5716
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.26100.3476

Reproduce

  1. open Docker Desktop
  2. hang on to Engine Starting a long time
  3. error occurred

Expected behavior

normal start

docker version

Client:
 Version:           28.0.1
 API version:       1.48
 Go version:        go1.23.6
 Git commit:        068a01e
 Built:             Wed Feb 26 10:41:52 2025
 OS/Arch:           windows/amd64
 Context:           desktop-linux
error during connect: Get "http://%2F%2F.%2Fpipe%2FdockerDesktopLinuxEngine/v1.48/version": open //./pipe/dockerDesktopLinuxEngine: The system cannot find the file specified.

docker info

Client:
 Version:    28.0.1
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  ai: Docker AI Agent - Ask Gordon (Docker Inc.)
    Version:  v0.9.4
    Path:     C:\Users\Cayin\.docker\cli-plugins\docker-ai.exe
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.21.1-desktop.2
    Path:     C:\Users\Cayin\.docker\cli-plugins\docker-buildx.exe
  compose: Docker Compose (Docker Inc.)
    Version:  v2.33.1-desktop.1
    Path:     C:\Users\Cayin\.docker\cli-plugins\docker-compose.exe
  debug: Get a shell into any image or container (Docker Inc.)
    Version:  0.0.38
    Path:     C:\Users\Cayin\.docker\cli-plugins\docker-debug.exe
  desktop: Docker Desktop commands (Beta) (Docker Inc.)
    Version:  v0.1.5
    Path:     C:\Users\Cayin\.docker\cli-plugins\docker-desktop.exe
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.2
    Path:     C:\Users\Cayin\.docker\cli-plugins\docker-dev.exe
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.27
    Path:     C:\Users\Cayin\.docker\cli-plugins\docker-extension.exe
  feedback: Provide feedback, right in your terminal! (Docker Inc.)
    Version:  v1.0.5
    Path:     C:\Users\Cayin\.docker\cli-plugins\docker-feedback.exe
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v1.4.0
    Path:     C:\Users\Cayin\.docker\cli-plugins\docker-init.exe
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     C:\Users\Cayin\.docker\cli-plugins\docker-sbom.exe
  scout: Docker Scout (Docker Inc.)
    Version:  v1.16.3
    Path:     C:\Users\Cayin\.docker\cli-plugins\docker-scout.exe

Server:
ERROR: error during connect: Get "http://%2F%2F.%2Fpipe%2FdockerDesktopLinuxEngine/v1.48/info": open //./pipe/dockerDesktopLinuxEngine: The system cannot find the file specified.
errors pretty printing info

Diagnostics ID

B90C0737-CB86-4516-AEFD-A98DBD11CA83/20250319062602

Additional Info

No response

Cayincc avatar Mar 19 '25 06:03 Cayincc

Did you use a proxy?

simexce avatar Mar 19 '25 06:03 simexce

Did you use a proxy?

yes

❯ echo $HTTP_PROXY
http://127.0.0.1:7890
❯ echo $HTTPS_PROXY
http://127.0.0.1:7890

Cayincc avatar Mar 19 '25 08:03 Cayincc

When I switched WSL to mirrored mode, Docker Desktop couldn't launch.

  1. .wslconfig
[wsl2]
networkingMode=mirrored
firewall=false

[experimental]
autoMemoryReclaim=gradual
sparseVhd=true
hostAddressLoopback=true
  1. Abnormal information:
running engine: waiting for the Docker API: context deadline exceeded
  1. Diagnostics ID

71DD2F76-F710-49C4-A081-F0FFED4A5A11/20250319065650

  1. Solution

Add *.docker.internal to NO_PROXY. This can be configured in the proxy software.

The image cannot be pulled.

  1. Abnormal information for docker pull nginx.
Using default tag: latest
Error response from daemon: Get "https://registry-1.docker.io/v2/": proxyconnect tcp: dial tcp 127.0.0.1:1080: connect: connection refused
  1. Testing with curl:
$ curl -x http://127.0.0.1:1080 https://www.google.com  
# Normal response.

$ curl -x http://127.0.0.1:1080 https://registry-1.docker.io/v2/  
# Response: {"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":null}]}
  1. Attempted fix:

Tried starting the container before configuring the proxy.

Goal: Docker Desktop should correctly use the system proxy.

simexce avatar Mar 19 '25 08:03 simexce

In previous Docker versions, this configuration worked fine though

# .wslconfig
[wsl2]
networkingMode=mirrored
dnsTunneling=true
firewall=true
autoProxy=true

[experimental]
# requires dnsTunneling but are also OPTIONAL
bestEffortDnsParsing=true
#useWindowsDnsCache=true

Cayincc avatar Mar 19 '25 08:03 Cayincc

  1. Solution Add *.docker.internal to NO_PROXY. This can be configured in the proxy software.
❯ curl -iv gateway.docker.internal
* Uses proxy env variable no_proxy == 'kubernetes.docker.internal,gateway.docker.internal,host.docker.internal,192.168.*,172.31.*,172.30.*,172.29.*,172.28.*,172.27.*,172.26.*,172.25.*,172.24.*,172.23.*,172.22.*,172.21.*,172.20.*,172.19.*,172.18.*,172.17.*,172.16.*,10.*,127.*,localhost,<local>'
* Host gateway.docker.internal:80 was resolved.
* IPv6: (none)
* IPv4: 192.168.101.14
*   Trying 192.168.101.14:80...
* connect to 192.168.101.14 port 80 from 192.168.101.14 port 43944 failed: Connection refused

Image

The method to bypass the proxy, I tried it, but it didn’t work in my case—still unable to start the Engine.

Cayincc avatar Mar 19 '25 08:03 Cayincc

Have Similar Issue

My .wslconfig

[wsl2]
#dnsTunneling = true
# AI told me to do this and it does not work
# 2025-03-09 - JMK Does not work
# networkingMode=bridged
# vmSwitch=WSL2Switch
networkingMode=mirrored
dnsTunneling=true
autoProxy=true
ipv6=false

My Docker Desktop error

running engine: waiting for the Docker API: context deadline exceeded

My Diagnostics ID

D52409E8-E4E4-41A6-A570-738924E0BEEB/20250319183623

jkruebbe avatar Mar 19 '25 18:03 jkruebbe

It looks like my previous podman config is conflicting with the docker config

docker info Client: Docker Engine - Community Version: 25.0.4 Context: default Debug Mode: false Plugins: buildx: Docker Buildx (Docker Inc.) Version: v0.13.0 Path: /usr/libexec/docker/cli-plugins/docker-buildx compose: Docker Compose (Docker Inc.) Version: v2.24.7 Path: /usr/libexec/docker/cli-plugins/docker-compose

ERROR: permission denied while trying to connect to the Docker daemon socket at unix:///run/podman/podman.sock: Get "http://%2Frun%2Fpodman%2Fpodman.sock/v1.44/info": dial unix /run/podman/podman.sock: connect: permission denied errors pretty printing info

jkruebbe avatar Mar 19 '25 18:03 jkruebbe

Since it seems there is no easy way to make both work together ( podman and docker desktop) I have disabled docker with:

sudo systemctl disable docker

jkruebbe avatar Mar 19 '25 21:03 jkruebbe

@jkruebbe

ERROR: permission denied while trying to connect to the Docker daemon socket at unix:///run/podman/podman.sock: Get "http://%2Frun%2Fpodman%2Fpodman.sock/v1.44/info": dial unix /run/podman/podman.sock: connect: permission denied errors pretty printing info

It seems like a Unix socket file permissions issue. You can modify the Podman socket permissions or adjust the user group settings.

Cayincc avatar Mar 20 '25 00:03 Cayincc

I also have the same issue, I'm also using a proxy

However, it was found that if the network mode of WSL changed to an option other than mirrored, this problem can be avoided

TonyBlur avatar Mar 22 '25 07:03 TonyBlur

Have the same problem. NAT and VirtioProxy will start docker engine but Mirrored won't.

GuoHaoxuan avatar Mar 24 '25 13:03 GuoHaoxuan

Also start failed with a TUN adaptor.

GuoHaoxuan avatar Mar 28 '25 10:03 GuoHaoxuan

  1. Solution

Add *.docker.internal to NO_PROXY. This can be configured in the proxy software.

In my case, this way worked.

Here I try to put down some ways I used to resolve the problem which is when using proxy that docker desktop is always starting. My system environment:

  • proxy tool: clash verge
  • os: windows 11
  • docker desktop version: v4.39.0
  • WSL integration: Ubuntu-24.04
  • my .wslconfig content:
    [experimental]
    networkingMode=mirrored
    dnsTunneling=true
    firewall=true
    autoProxy=true
    hostAddressLoopback=true
    

Option 1. start docker desktop before clash starting, then docker desktop will started successfully.

Option 2. click switch to windows containters... , but there docker will cant be used on WSL, and no Resource -> Advanced in Settings. Image

Option 3. Configure *.docker.internal to bypass the proxy in the proxy tool. Example: Image

yzztin avatar Apr 01 '25 01:04 yzztin

@yzztin It's unrelated to the HTTP proxy; internal communication uses a pipe. To launch it on WSL, simply change mirrored to nat. Mirrored mode currently has a bug, and the official patch hasn’t been released yet.

Cayincc avatar Apr 01 '25 02:04 Cayincc