File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+
2+ ``` bash
3+
4+ # wsl2 get windows host
5+ HOST_IP=$( ip route show default | awk ' { print $3 }' )
6+
7+ sudo mkdir -p /etc/systemd/system/docker.service.d/
8+ cat << EOF | sudo tee /etc/systemd/system/docker.service.d/http-proxy.conf
9+ [Service]
10+ Environment="HTTP_PROXY=http://${HOST_IP} :7890"
11+ Environment="HTTPS_PROXY=http://${HOST_IP} :7890"
12+ Environment="NO_PROXY=localhost,127.0.0.1"
13+ EOF
14+
15+ echo " reloading systemctl daemon..."
16+ sudo systemctl daemon-reexec
17+ sudo systemctl daemon-reload
18+ echo " restarting docker daemon..."
19+ sudo systemctl restart docker
20+
21+ echo " lookuping docker proxy env..."
22+ systemctl show --property=Environment docker
23+
24+ echo " to cancel proxy, delete /etc/systemd/system/docker.service.d/http-proxy.conf"
25+ ```
Original file line number Diff line number Diff line change 1+ - https://hub.docker.com
2+
3+ - 仓库必须有latest tag才能用latest tag进行拉去,而不是自动给最新的tag
Original file line number Diff line number Diff line change 1+ - 设置变量
2+ - http_proxy
3+ - https_proxy
4+ - all_proxy
5+ - 一般只需要设置`http://host:port`即可,windows无all_proxy
6+
Original file line number Diff line number Diff line change 1+ ``` bash
2+ PROXY_PORT=7890
3+ WIN_HOST=$( ip route show | grep -i default | awk ' { print $3}' )
4+ export WIN_HOST=$WIN_HOST
5+ export http_proxy=http://$WIN_HOST :$PROXY_PORT
6+ export https_proxy=http://$WIN_HOST :$PROXY_PORT
7+ export all_proxy=socks5h://$WIN_HOST :$PROXY_PORT
8+ ```
You can’t perform that action at this time.
0 commit comments