Troubleshooting Docker on Ubuntu under WSL2 with Docker Desktop

Abstract: Fix Docker pull failures on Ubuntu under WSL2 by configuring proxy environment variables, updating daemon.json, and installing corporate CA certificates.

Created: 2026-10-05 by

Resolve Docker pull failures on Ubuntu under WSL2 by verifying proxy environment variables and ensuring the Docker Desktop WSL2 backend is correctly configured. Common errors like proxyconnect DNS lookup stem from misconfigured network settings or missing certificates, which can be fixed by updating .docker/config.json and restarting the engine.

Understanding the ProxyConnect Error

When attempting to pull images using docker pull in an Ubuntu environment running within WSL2, you may encounter a connection error that mentions proxyconnect or DNS lookups failing. This specific error indicates that the Docker daemon is trying to route traffic through an HTTP or HTTPS proxy, but it cannot resolve the proxy server's hostname or establish a secure connection. This is particularly common in corporate environments where all external traffic must pass through a designated gateway. The issue often arises because the Docker daemon runs as a Linux process inside the WSL2 instance, while the proxy configuration might be set at the Windows host level or not propagated correctly into the Linux subsystem. If the proxy requires SSL interception (common in enterprise security setups), the Docker client also needs access to the internal Certificate Authority (CA) certificate to validate the proxy's identity. Without this, the TLS handshake fails, resulting in the DNS lookup or connection refusal error.

Verifying Environment Variables

The first step is to ensure that your shell environment correctly defines the proxy settings. In Ubuntu within WSL2, these are typically stored in /etc/environment or user-specific profile files. Check if http_proxy, https_proxy, and no_proxy are set. You can verify this by running:
env | grep -i proxy
If these variables are empty, Docker will attempt a direct connection, which might fail if your network policy blocks direct internet access. Conversely, if they contain incorrect URLs or IPs, Docker will fail to connect to the proxy itself. Ensure the URL format is correct, including the port number, such as http://proxy.company.com:8080.

Configuring Docker Daemon Settings

Even if your shell has the correct proxy variables, the Docker daemon itself does not automatically inherit them. You must configure the Docker daemon to use the proxy explicitly. This is done by editing the daemon.json file located at /etc/docker/daemon.json in your WSL2 Ubuntu instance. Create or modify this file to include the proxy settings for both HTTP and HTTPS. For example:
{
  "proxies": {
    "http-proxy": "http://user:[email protected]:8080",
    "https-proxy": "https://user:[email protected]:8080",
    "no-proxy": "localhost,127.0.0.1,.internal.domain"
  }
}
After saving the file, restart the Docker service to apply the changes. In WSL2 with Docker Desktop, you can do this by stopping the WSL distribution and then restarting Docker Desktop, or by running sudo systemctl restart docker if you are managing the daemon directly within WSL. Note that Docker Desktop manages its own backend, so sometimes restarting the entire Docker Desktop application from the Windows taskbar icon is more effective than restarting the service inside WSL.

Handling Corporate CA Certificates

If your proxy uses a self-signed certificate or an internal CA, you must add the CA certificate to the trusted store of the Docker daemon. Copy the .crt file to /usr/local/share/ca-certificates/ in your WSL2 Ubuntu instance. Then, run sudo update-ca-certificates to refresh the trust store. Finally, ensure the Docker daemon is restarted so it picks up the new certificates. Failure to do this will result in SSL verification errors during image pulls.

Docker Desktop WSL2 Backend Configuration

Docker Desktop on Windows uses WSL2 as a backend engine. It is crucial to ensure that the integration between Docker Desktop and your Ubuntu WSL2 instance is active. Go to Docker Desktop settings, navigate to Resources > WSL Integration, and verify that your Ubuntu distribution is toggled on. If integration is disabled, Docker commands executed in WSL may not communicate properly with the Docker daemon running on the Windows host. Additionally, check if there are any firewall rules on the Windows host blocking outbound connections from the WSL2 virtual switch. While less common, firewall interference can mimic proxy errors. You can test connectivity from within WSL2 by pinging the proxy IP or using curl to test the proxy endpoint directly. For more details on managing resources in this setup, see Managing Memory and Processor Swap in WSL2 with Docker Desktop on Ubuntu. Proper resource allocation ensures that the WSL2 instance can handle network I/O without throttling, which might otherwise contribute to timeout-related issues.

Troubleshooting Network Connectivity

If proxy configuration appears correct but issues persist, diagnose the underlying network path. Use nslookup or dig inside WSL2 to check if the proxy hostname resolves correctly. If DNS resolution fails, check your /etc/resolv.conf file. WSL2 often uses a dynamic DNS resolver provided by the Windows host. If this resolver is unreachable or misconfigured, all domain lookups will fail. You can also try bypassing the proxy temporarily by setting NO_PROXY=* to see if the issue is strictly related to the proxy configuration or general network reachability. If images pull successfully without the proxy, the problem is isolated to the proxy credentials, URL, or certificate chain. For scenarios involving complex networking between hosts, reviewing how to ping WSL2 from Windows can help isolate whether the issue is specific to Docker or broader network stack problems. Refer to How to Ping WSL2 Ubuntu from Windows Host for diagnostic steps on basic connectivity.

Cleaning Up and Rebuilding

After applying fixes, it is good practice to clear any cached connection attempts. Run docker system prune to remove unused data, though this primarily affects storage. More importantly, ensure no stale processes are holding onto old network configurations. Restarting Docker Desktop completely flushes the state of the WSL2 backend and re-establishes network interfaces. If you frequently pull large images and notice disk space issues, consider optimizing your storage usage. See Reclaim Space of Pruned Images in Docker WSL for tips on managing disk usage effectively in this environment.

Frequently Asked Questions

Why does docker pull work on Windows but fail in WSL2?

This usually happens because the Docker daemon inside WSL2 does not inherit the Windows environment variables for proxies. You must configure the proxy settings explicitly in the Docker daemon's daemon.json file within the Linux subsystem, rather than relying on Windows shell settings.

How do I fix SSL errors when using a corporate proxy?

You need to install the corporate Certificate Authority (CA) certificate into the WSL2 Ubuntu trust store. Place the .crt file in /usr/local/share/ca-certificates/ and run sudo update-ca-certificates, then restart the Docker service to apply the changes.

What should I do if DNS lookups fail inside WSL2?

Check the contents of /etc/resolv.conf to ensure it points to a valid DNS server. WSL2 relies on the Windows host for DNS resolution; if the host's DNS is unreachable or blocked, update the resolver configuration or ensure Windows firewall allows outbound DNS traffic from the WSL2 virtual adapter.

Can I use different proxy settings for different users?

Yes, you can configure per-user proxy settings in ~/.docker/config.json or via shell environment variables. However, the Docker daemon itself reads global settings from /etc/docker/daemon.json. For user-specific pulls, ensure the shell environment passed to the daemon is consistent.

Does Docker Desktop automatically sync proxy settings from Windows?

No, Docker Desktop does not automatically sync Windows proxy settings into the WSL2 Linux backend. You must manually configure the proxy in the Docker daemon settings within WSL2 or use a startup script to export the necessary environment variables before starting the Docker service.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More