Total Pageviews

Saturday 24 October 2020

Mac os下,设置docker的代理

 编辑 ~/.docker/machine/machines/default/config.json

    "HostOptions": {
        "Driver": "",
        "Memory": 0,
        "Disk": 0,
        "EngineOptions": {
            "ArbitraryFlags": [],
            "Dns": null,
            "GraphDir": "",
            "Env": [
				"HTTP_PROXY=http://192.168.99.1:8118",
				"HTTPS_PROXY=http://192.168.99.1:8118",
				"NO_PROXY=localhost,127.0.0.1,192.168.99.100"
            ],

要生效的话,必须执行以下命令

docker-machine provision

设置好代理后,docker pull 跑得飞快:)

系统内部代理

cat > /etc/apt/apt.conf <<\EOF
Acquire::http::Proxy "http://192.168.99.1:8118";
EOF
--------

linux下,设置Docker的代理


  • 创建目录
mkdir /etc/systemd/system/docker.service.d
  • 创建文件并加入以下内容
cat >/etc/systemd/system/docker.service.d/http-proxy.conf << EOF
[Service] 
Environment="HTTP_PROXY=http://192.168.1.128:8118"
Environment="HTTPS_PROXY=http://192.168.1.128:8118"
Environment="NO_PROXY=localhost,127.0.0.1"
EOF
  • 更新重加载配置&重启Docker服务
systemctl daemon-reload 
systemctl restart docker

No comments:

Post a Comment