Docker Proxy Configuration
Background
Due to certain domains being inaccessible from the company network, we need to go through a proxy to access the external internet. Most of the time, setting the following environment variables should suffice:
|
|
However, there are cases where different services require specific proxy settings. For instance, Python’s package manager pip
requires the --proxy
parameter during installation.
Initially, I didn’t realize that Docker also needed its own proxy configuration. When using the docker pull
command, I kept encountering this error:
|
|
Solution
After some investigation, I found out that Docker’s proxy settings need to be added via a configuration file, specifically for CentOS, create the file /etc/systemd/system/docker.service.d/http-proxy.conf
:
|
|
|
|
Then, restart the Docker service:
|
|
Now, you should be able to successfully download Docker images using docker pull
!