Resolving 'Network Timed Out' Issues
Once you've identified the potential causes of the "network timed out" error when pulling Docker images, you can try the following solutions to resolve the issue.
Checking Network Connectivity
Ensure that the Docker host has a stable and reliable network connection. You can test the connectivity by running the following command:
$ ping docker.com
PING docker.com (104.18.122.50) 56(84) bytes of data.
64 bytes from 104.18.122.50 (104.18.122.50): icmp_seq=1 ttl=55 time=10.2 ms
If the ping command fails or shows high latency, there might be a network issue that needs to be addressed.
Verifying Registry Availability
Check the status of the Docker registry you're trying to pull from. You can use a tool like curl
to test the registry's availability:
$ curl https://registry-1.docker.io/v2/
{"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":null}]}
If the registry is unavailable or experiencing issues, you may need to wait for the problem to be resolved or try a different registry.
Increasing Timeout Limits
You can try increasing the Docker client's timeout limits to allow more time for the image pulling process to complete. Edit the Docker daemon configuration file (/etc/docker/daemon.json
) and add the following lines:
{
"timeout": 120
}
This will set the timeout to 120 seconds (2 minutes). Restart the Docker service for the changes to take effect.
$ sudo systemctl restart docker
Clearing the Docker Cache
Clearing the Docker image cache can sometimes resolve network-related issues. You can do this by running the following commands:
$ docker system prune --all --force --volumes
$ docker pull ubuntu:22.04
The docker system prune
command will remove all unused data, including images, containers, and volumes.
Checking Proxy Settings
If the Docker host is behind a proxy, ensure that the proxy settings are correctly configured in the Docker daemon configuration file (/etc/docker/daemon.json
):
{
"proxies": {
"default": {
"httpProxy": "http://proxy.example.com:8080",
"httpsProxy": "http://proxy.example.com:8080",
"noProxy": "localhost,127.0.0.1"
}
}
}
Restart the Docker service after making any changes to the proxy settings.
By following these steps, you should be able to resolve the "network timed out" error when pulling Docker images.