Skip to content

Instantly share code, notes, and snippets.

@log2c
Created December 12, 2023 05:51
Show Gist options
  • Save log2c/6cc318c31a89a5ee0d3c3faaa353d575 to your computer and use it in GitHub Desktop.
Save log2c/6cc318c31a89a5ee0d3c3faaa353d575 to your computer and use it in GitHub Desktop.
Docker设置代理

创建目录

mkdir /etc/systemd/system/docker.service.d

创建文件

/etc/systemd/system/docker.service.d/http-proxy.conf

填入内容

[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/"
Environment="HTTPS_PROXY=http://proxy.example.com:80/"
# 如果需要绕过
Environment="NO_PROXY=localhost,127.0.0.0/8,docker-registry.somecorporation.com"

重载

$ sudo systemctl daemon-reload

重启Docker

$ sudo systemctl restart docker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment