current position:Home>Docker failed to pull image processing

Docker failed to pull image processing

2022-01-26 22:23:17 Yan Long


If the network environment of the master needs to be configured with an agent to access the Internet , That installation docker after , To pull the image probability will fail . Errors like the following :

[email protected]:~$ docker pull ubuntu:latest
Error response from daemon: Get net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

Question why

When the master machine accesses the external network through an agent , Usually in the command line through export To set up a proxy

export http_proxy=http://*****:8080
export https_proxy=http://*****:8080

and docker The mirror image is pulled through docker daemon Service complete ,docker daemon The service is in another process , Will not read the current shell Command line agent , therefore docker pull Will fail .

Official documents


1、 stay /etc/systemd/system/docker.service.d/http-proxy.conf Add agent information to the configuration file 2、 restart docker service

The specific operation is as follows :

  1. establish dockerd dependent systemd Catalog , The configuration in this directory will overwrite dockerd Default configuration
$ sudo mkdir -p /etc/systemd/system/docker.service.d
  1. New configuration file /etc/systemd/system/docker.service.d/http-proxy.conf The contents are as follows :

tips: If the file already exists , You can directly modify the contents of the file , Add relevant proxy settings

If there is an address that does not need an agent , Additable NO_PROXY To configure :


Multiple NO_PROXY The values of variables are separated by commas , And you can use wildcards (), In extreme cases , If NO_PROXY=, Then all requests will not pass through the proxy server

  1. Reload the configuration file , restart dockerd service
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
  1. docker info View configuration results

Conclusion :

docker Image by docker daemon management , So it can't be modified shell The method of environment variable uses proxy service , But from systemd Angle sets the environment variable

Reference material

1、 2、

copyright notice
author[Yan Long],Please bring the original link to reprint, thank you.

Random recommended