Tutorial Featured Clash Beginner Guide Clash vs VPN Proxy Basics

Fix Docker Hub Timeouts with Clash Transparent Proxy Setup

July 23, 2026 Updated July 23, 2026 Approx. 12 min read

Why Docker Hub Times Out Behind Clash

Docker image pulls can fail even when ordinary websites open normally through Clash. A command such as docker pull nginx:latest may pause for several minutes and then return i/o timeout, context deadline exceeded, or Client.Timeout exceeded while awaiting headers. This usually does not mean that Docker Hub is completely unavailable. More often, the Docker Engine is using a different network path from your browser, while Clash is only proxying applications that understand the system proxy.

There is another complication: a Docker pull is not a single request to one hostname. The client may contact registry-1.docker.io for registry operations, auth.docker.io for authentication, and a content delivery network such as production.cloudflare.docker.com or another storage endpoint for image layers. If only one of these domains is routed incorrectly, authentication can succeed while the actual layer download times out.

This guide presents a practical Clash transparent proxy setup for Docker on a local computer or server. It covers TUN mode, Docker Engine proxy variables, DNS behavior, rule order, node selection, and log-based troubleshooting. The examples use Mihomo-compatible configuration syntax, but the same principles apply to many Clash clients that expose a TUN or redirection feature.

The Target

Make Docker Hub authentication and layer downloads follow one predictable Clash route, while keeping unrelated local traffic on DIRECT whenever possible.

1Understand the Docker and Clash Traffic Path

Before changing configuration, identify which component is making the request. A browser usually honors HTTP or SOCKS proxy settings configured by the operating system or by the Clash client. The Docker command-line tool, however, communicates with the Docker daemon. On Linux, that daemon commonly runs as a system service under systemd; on Windows and macOS, Docker Desktop runs the engine inside a managed virtual machine. The process that needs proxy access is therefore often the daemon, not the terminal window where you type the command.

Transparent proxying solves a different problem. Instead of requiring every application to support a proxy, Clash captures traffic at the network layer through TUN, redirection, or a similar mechanism. This can help Docker containers and daemon traffic, but it depends on permissions, route settings, DNS interception, and whether Docker is running inside a separate virtual machine.

Layer What it controls Typical failure
Clash client Proxy nodes, mode, TUN, DNS, and rules TUN is disabled or the wrong mode is selected
Docker daemon Registry authentication and image downloads Daemon ignores the desktop system proxy
DNS resolver Maps Docker domains to IP addresses Local DNS returns a blocked or unreachable address
Registry and CDN Authentication, manifests, and image layers Only the CDN domain is left outside the proxy

The first diagnostic question is simple: does the same machine reach Docker Hub through a browser or curl, but fail with docker pull? If yes, focus on Docker daemon proxy settings and transparent capture rather than immediately replacing the proxy subscription.

2Configure Clash Transparent Proxy Mode

For a desktop installation, TUN mode is normally the easiest transparent approach. Open your Clash client, select the active profile, and enable the TUN or enhanced network mode. The exact label differs between Clash Verge Rev, Mihomo Party, and other clients. Administrator or root permission may be required because the client must create a virtual network interface and modify routes.

A basic Mihomo configuration can look like this:

mixed-port: 7890 allow-lan: false mode: rule log-level: info tun: enable: true stack: mixed auto-route: true auto-detect-interface: true strict-route: true dns-hijack: - any:53 dns: enable: true ipv6: false enhanced-mode: fake-ip fake-ip-range: 198.18.0.1/16 nameserver: - https://1.1.1.1/dns-query - https://dns.google/dns-query fallback: - https://cloudflare-dns.com/dns-query - https://dns.quad9.net/dns-query

The important options are auto-route, which installs routes through the TUN interface, and dns-hijack, which allows Clash to intercept ordinary port 53 queries. fake-ip mode can prevent local DNS results from bypassing the proxy decision. If your client or operating system has compatibility problems with fake IP, test redir-host instead, but do not change several network variables at once.

Important Boundary

TUN mode on the host does not automatically capture traffic from every Docker Desktop virtual machine, remote Docker context, or separately routed server. In those cases, configure the daemon or the virtual machine explicitly as well.

Choose a stable proxy group

Do not test Docker with an automatic latency group that changes nodes during a pull. Large images contain many layers, and switching nodes halfway through a download can produce inconsistent authentication or broken connections. Select one stable node manually, preferably with low packet loss, reliable HTTPS support, and enough bandwidth for large files. A node that is fast in a browser may still perform poorly with long-lived registry downloads.

3Set the Docker Engine Proxy Explicitly

Transparent routing is useful, but an explicit daemon proxy is often more predictable. It tells Docker where to send registry requests even when the daemon is not fully captured by TUN. Use the HTTP proxy address exposed by Clash, commonly 127.0.0.1:7890 when Docker and Clash share the same network namespace.

On a Linux host using systemd, create a drop-in directory and configuration file:

sudo mkdir -p /etc/systemd/system/docker.service.d sudo tee /etc/systemd/system/docker.service.d/http-proxy.conf <<'EOF' [Service] Environment="HTTP_PROXY=http://127.0.0.1:7890" Environment="HTTPS_PROXY=http://127.0.0.1:7890" Environment="NO_PROXY=localhost,127.0.0.1,::1" EOF sudo systemctl daemon-reload sudo systemctl restart docker

Check that the daemon received the variables:

sudo systemctl show --property=Environment docker docker info

Some Docker installations use a different service name, such as docker.service or a rootless user service. Confirm the active unit with systemctl status docker. If Docker runs in rootless mode, place the drop-in under the user systemd directory and restart the user service instead of modifying the system daemon.

On Docker Desktop, open the application settings and look for the Resources, Proxies, or Network section. Depending on the release, Docker Desktop may provide a proxy field, or it may inherit the host proxy. If you use a local Clash listener, verify whether Docker Desktop can access the host loopback address. Inside a virtual machine, 127.0.0.1 refers to that virtual machine, not necessarily the host running Clash. You may need the host gateway address, a LAN listener, or the proxy setting provided by Docker Desktop.

Security Note

If you expose Clash with allow-lan: true, bind it only to a trusted interface and protect the management panel. Never leave an unauthenticated proxy listener reachable from the public internet.

4Add Docker Hub Rules and Verify DNS

Rule order matters because Clash evaluates rules from top to bottom and stops at the first match. Put specific Docker domains above broad rules such as a regional geolocation rule, a catch-all GEOIP rule, or the final MATCH rule. A practical starting point is:

rules: - DOMAIN,auth.docker.io,PROXY - DOMAIN,registry-1.docker.io,PROXY - DOMAIN,hub.docker.com,PROXY - DOMAIN-SUFFIX,docker.com,PROXY - DOMAIN-SUFFIX,docker.io,PROXY - DOMAIN-SUFFIX,dockerusercontent.com,PROXY - DOMAIN-SUFFIX,cloudflare.docker.com,PROXY - MATCH,DIRECT

The exact layer download hostname can vary. Start a pull while watching Clash logs, then add the domain that appears in the connection record. Avoid blindly proxying every cloud provider domain, because Docker image layers may be hosted on infrastructure shared with many unrelated services. Domain rules are easier to audit than a large collection of guessed IP ranges.

DNS must follow the same policy as the connection. Test resolution from the host:

nslookup registry-1.docker.io nslookup auth.docker.io curl -I https://registry-1.docker.io/v2/

A healthy registry endpoint may return 401 Unauthorized from /v2/; that response is not necessarily an error. It confirms that HTTPS reached the registry and that authentication is required. By contrast, a DNS failure, connection reset, or long hang indicates a routing or resolution problem.

When fake IP mode is enabled, some applications may display addresses from the reserved fake range rather than the real Docker server. That is expected. Do not add fake IP addresses to permanent allowlists. If a Docker component rejects fake IP responses, add the affected domain to fake-ip-filter or temporarily test redir-host mode:

dns: fake-ip-filter: - "*.lan" - "*.local" - "localhost.ptlogin2.qq.com"

Use exclusions sparingly. Excluding Docker domains from Clash DNS can reintroduce local resolver failures, especially when the original timeout is caused by DNS interference.

5Hands-On Setup and Test Procedure

Apply the configuration in a controlled sequence so that each test tells you something useful. The following workflow works well on Linux and can be adapted to Docker Desktop.

A Reliable Docker Pull Checklist
  1. Update the Clash profile and select one known-good proxy node. Confirm that ordinary HTTPS traffic works through that node.
  2. Enable TUN mode with automatic routes and DNS hijacking. Approve the administrator prompt, then verify that the virtual interface appears.
  3. Restart Clash before restarting Docker. This prevents Docker from retaining an old route or stale resolver state during the first test.
  4. Test the registry endpoint with curl -I https://registry-1.docker.io/v2/. A 401 response generally proves that the HTTPS path is alive.
  5. Run docker login and observe both the Clash connection log and the Docker daemon log. Confirm that authentication domains are routed to the intended policy group.
  6. Pull a small image such as busybox:latest before testing a large image. This separates basic connectivity from bandwidth and timeout issues.
  7. Pull the target image with progress output, for example docker pull ubuntu:24.04. If it fails, record the layer number and the last hostname shown in Clash.
  8. After a successful pull, restart Docker once more and repeat the command. A cached image can hide a configuration problem, so test a tag that is not already present when practical.

For deeper inspection, use docker system info and check the daemon logs:

sudo journalctl -u docker -f docker system info docker pull --quiet busybox:latest

Do not judge the setup only by the speed of the first layer. A reliable route should complete authentication, manifest retrieval, and every layer without repeated retries. If the first few layers are quick but later layers stall, inspect the CDN hostname rather than changing the Docker registry rule.

6Read Logs and Fix the Most Common Failures

Clash logs are most useful when filtered by the time of the failed pull. Look for the requested host, selected rule, policy group, and connection result. If auth.docker.io is shown as DIRECT while registry-1.docker.io uses PROXY, the rule list is incomplete or ordered incorrectly. If no Docker hostname appears at all, the daemon traffic is probably bypassing Clash and the explicit proxy or route needs attention.

Symptom Likely cause Recommended action
Browser works, Docker times out Docker daemon ignores the system proxy Set HTTP_PROXY and HTTPS_PROXY for the daemon, then restart it
401 from registry Registry is reachable and requests authentication Run docker login; do not treat this response as a network failure
Login succeeds, layers timeout CDN or object-storage domain is not proxied Inspect Clash logs and add the precise domain rule
Intermittent resets Unstable node, MTU issue, or overloaded route Switch to a stable node and test a lower TUN MTU if supported
DNS resolves but connection hangs Resolved address is unreachable or route is DIRECT Check DNS policy, rule matching, and the selected outbound interface

MTU problems are less common but can appear on VPN, TUN, PPPoE, or nested virtualization networks. Symptoms include successful small requests but stalled large TLS transfers. If your Clash client exposes an MTU option, test a conservative value such as 1400 or 1380, then retest. Change only one value at a time and keep a record of the original setting.

Another common mistake is proxying the daemon to 127.0.0.1:7890 when the daemon runs in a container or virtual machine. In that environment, use a reachable host address and ensure the Clash listener accepts connections from that network. Conversely, do not use 0.0.0.0 as a public-facing solution without firewall restrictions.

7Keep the Configuration Reliable

A Docker-specific proxy setup should be simple enough to maintain. Keep the Docker rules near the top of the rule list, document why each domain is included, and avoid copying large IP lists from unverified sources. Docker infrastructure changes over time, while a small set of domain rules can be updated after checking current logs.

  • Use a dedicated proxy group for Docker when your client supports it, so image pulls do not unexpectedly switch nodes.
  • Keep NO_PROXY entries for local registries, private networks, and internal service names that should never leave the local network.
  • Do not enable both several competing VPN clients and Clash TUN mode during troubleshooting; overlapping routes make results difficult to interpret.
  • Test authentication and an uncached image after every major profile update.
  • Monitor disk space as well as network logs. Docker may report an apparent download failure when the filesystem is full.
  • For production servers, consider a nearby pull-through registry cache. It reduces repeated downloads and makes deployments less dependent on an interactive desktop proxy.

Transparent proxying is a routing technique, not a guarantee that every proxy node can handle Docker Hub. Choose nodes with dependable HTTPS connectivity, avoid frequently changing automatic groups, and keep a direct fallback only when your network can actually reach the registry without restrictions.

Frequently Asked Questions

Does Docker automatically use Clash system proxy settings?

Usually not. The Docker CLI sends requests to the Docker daemon, and the daemon may run as a separate service or inside a virtual machine. Configure the daemon proxy explicitly, use Docker Desktop's proxy settings, or capture the daemon traffic with a correctly configured TUN route.

Why does docker login work while docker pull fails?

Authentication and layer downloads can use different hostnames. The registry and authentication endpoints may match your PROXY rules, while the image layers come from a CDN or object-storage domain that is still routed DIRECT. Watch Clash logs during the layer phase and add the missing domain.

Is a 401 Unauthorized response from Docker Registry an error?

Not by itself. A request to /v2/ commonly returns 401 to indicate that the registry is reachable but requires credentials or a token. A timeout, DNS error, TLS failure, or connection reset is more indicative of a routing problem.

Should every Docker domain be forced through the proxy?

Not necessarily. Proxy the registry, authentication, and observed layer-delivery domains that cannot be reached reliably through your local connection. Keep private registries and internal network names in NO_PROXY, and review the rules periodically to avoid unnecessary proxy traffic.

Download Clash for Free – Get Started Now →