The 'context deadline exceeded' error occurs when a Docker operation fails to complete within the allotted timeout period. This typically indicates network connectivity issues, DNS resolution failures, slow registry responses, or Docker daemon problems.
The "context deadline exceeded" error is a timeout message originating from Go's context package, which Docker uses internally. When you see this error, it means that a Docker API request or network operation took longer than the configured timeout and was cancelled. This error commonly appears during operations like pulling images from a registry, pushing images, or when the Docker daemon fails to respond in time. The "deadline" refers to the maximum time allowed for an operation to complete, and "exceeded" means that time limit was reached before the operation finished. The error is often a symptom of underlying network or infrastructure issues rather than a problem with Docker itself. It frequently indicates connectivity problems between your Docker client/daemon and container registries, DNS resolution failures, or resource constraints on the host system.
First, check if you can reach the Docker registry from your host:
# Test connectivity to Docker Hub
curl -I https://registry-1.docker.io/v2/
# Test DNS resolution
nslookup registry-1.docker.io
# Check for latency issues
ping -c 5 registry-1.docker.ioIf these commands fail or show high latency, you have a network connectivity issue that needs to be resolved first.
DNS misconfiguration is one of the most common causes. On Linux systems using systemd-resolved, Docker may not be able to use the localhost DNS resolver:
# Check current DNS configuration
cat /etc/resolv.confIf you see nameserver 127.0.0.53, configure Docker to use public DNS:
sudo nano /etc/docker/daemon.jsonAdd or update:
{
"dns": ["8.8.8.8", "8.8.4.4", "1.1.1.1"]
}Then restart Docker:
sudo systemctl restart dockerIf using Docker Compose, increase the HTTP timeout:
# Set environment variable before running compose
export COMPOSE_HTTP_TIMEOUT=200
# Or inline with the command
COMPOSE_HTTP_TIMEOUT=200 docker-compose upFor persistent configuration, add to your shell profile (~/.bashrc or ~/.zshrc):
export COMPOSE_HTTP_TIMEOUT=200For Kubernetes or orchestration platforms with internal timeouts, pre-pull large images manually:
# Pull the image directly (no orchestration timeout)
docker pull mcr.microsoft.com/mssql/server:2019-latest
# Verify it's cached locally
docker images | grep mssqlOnce cached locally, subsequent deployments will use the local image instead of timing out during download.
If using Docker Swarm, verify nodes are not in drain state:
# Check node availability
docker node ls
# Inspect specific node status
docker node inspect --format '{{.Spec.Availability}}' <node-name>If a node shows "drain", it cannot receive overlay network resources, causing deadline errors:
# Activate the node
docker node update --availability active <node-name>Docker Swarm requires specific ports for communication. Ensure these are open:
- TCP 2377: Cluster management communications
- TCP/UDP 7946: Node communication
- UDP 4789: Overlay network traffic
Check firewall rules:
# For firewalld
sudo firewall-cmd --list-all
# For ufw
sudo ufw status
# Open required ports (firewalld example)
sudo firewall-cmd --permanent --add-port=2377/tcp
sudo firewall-cmd --permanent --add-port=7946/tcp
sudo firewall-cmd --permanent --add-port=7946/udp
sudo firewall-cmd --permanent --add-port=4789/udp
sudo firewall-cmd --reloadVerify the Docker daemon is responsive:
# Check Docker service status
sudo systemctl status docker
# Test daemon responsiveness
docker info
# View daemon logs for errors
sudo journalctl -u docker -n 50 --no-pagerIf the daemon is unresponsive, restart it:
sudo systemctl restart dockerFor persistent issues, enable debug mode in /etc/docker/daemon.json:
{
"debug": true
}In Swarm clusters, mismatched versions can cause timeout issues:
# Check versions across all nodes
docker node ls --format '{{.Hostname}}: {{.EngineVersion}}'
# Or on each node individually
docker version --format '{{.Server.Version}}'If versions differ significantly, upgrade nodes to a consistent version:
# On Debian/Ubuntu
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.ioGitLab Runner Configuration: If using GitLab CI with Kubernetes executor, increase the poll_timeout in your runner's config.toml file to handle slower cluster API responses.
Azure Container Registry: For ACR-specific deadline issues, verify your registry's sign-in server DNS resolves correctly with nslookup <registry-name>.azurecr.io. Private endpoints may require specific DNS configuration.
Proxy Environments: In corporate environments, ensure Docker is configured to use your proxy:
{
"proxies": {
"default": {
"httpProxy": "http://proxy.example.com:8080",
"httpsProxy": "http://proxy.example.com:8080",
"noProxy": "localhost,127.0.0.1"
}
}
}BuildKit Timeouts: For docker build timeouts with BuildKit, you may see "failed to solve: DeadlineExceeded". This often relates to slow base image pulls. Consider using a local registry mirror or pre-caching base images.
Rootless Docker: In rootless mode, networking uses slirp4netns which can have different timeout characteristics. Consider adjusting slirp4netns settings if experiencing consistent timeouts.
WSL2 Considerations: On Windows with WSL2, network issues can arise from DNS configuration conflicts between Windows and the WSL2 VM. Try adding your Windows host DNS to the WSL2 resolv.conf.
image operating system "linux" cannot be used on this platform
How to fix 'image operating system linux cannot be used on this platform' in Docker
manifest unknown: manifest unknown
How to fix 'manifest unknown' in Docker
cannot open '/etc/passwd': Permission denied
How to fix 'cannot open: Permission denied' in Docker
Error response from daemon: failed to create the ipvlan port
How to fix 'failed to create the ipvlan port' in Docker
toomanyrequests: Rate exceeded for anonymous users
How to fix 'Rate exceeded for anonymous users' in Docker Hub