Docker
https://cloud.tencent.com/developer/article/1806455
在执行docker pull时,是由守护进程dockerd来执行。因此,代理需要配在dockerd的环境中。而这个环境,则是受systemd所管控,因此实际是systemd的配置。
sudo mkdir -p /etc/systemd/system/docker.service.d
sudo touch /etc/systemd/system/docker.service.d/proxy.conf
在这个proxy.conf文件(可以是任意*.conf的形式)中,添加以下内容:
[Service]
Environment="HTTP_PROXY=http://proxy.example.com:8080/"
Environment="HTTPS_PROXY=http://proxy.example.com:8080/"
Environment="NO_PROXY=localhost,127.0.0.1,.example.com"
其中,proxy.example.com:8080 要换成可用的免密代理。
Gitlab-Runner
https://docs.gitlab.com/runner/configuration/proxy.html
Adding the Proxy to the Docker containers
After you register your runner, you may want to propagate your proxy settings to the Docker containers (for example, for git clone).
To do this, you need to edit /etc/gitlab-runner/config.toml and add the following to the [[runners]] section:
pre_get_sources_script = "git config --global http.proxy $HTTP_PROXY; git config --global https.proxy $HTTPS_PROXY"
environment = ["https_proxy=http://docker0_interface_ip:3128", "http_proxy=http://docker0_interface_ip:3128", "HTTPS_PROXY=http://docker0_interface_ip:3128", "HTTP_PROXY=http://docker0_interface_ip:3128"]
Where docker0_interface_ip is the IP address of the docker0 interface.
In our examples, we are setting both lower case and upper case variables because certain programs expect HTTP_PROXY and others http_proxy. Unfortunately, there is no standard on these kinds of environment variables.