国内Linux 使用 http 代理,愉快使用 docker wget curl git apt
在使用
docker build打包镜像时,遇到了需要使用代理访问网络的需求。使用如下的Dockerfile来模拟这个场景:FROM golang RUN curl www.google.com --max-time 3- 国内一般网络环境下,
curl www.google.com是无法正常返回的,加入 --max-time 让 curl 的耗时不要太长。

我们知道Linux系统添加Http代理,可以使用如下命令,使用http代理支持的软件多一些
export http_proxy="http://192.168.1.135:8010"
export https_proxy="http://192.168.1.135:8010"
curl google.com现在把命令行改写成 http.sh 脚本,使用: . http.sh [ip:port]
# usage: . http.sh [ip:port]
http_proxy=http://192.168.1.135:8010
if [[ $# > 0 ]]; then
http_proxy=http://$1
fi
echo "export https_proxy=${http_proxy}"
export http_proxy=$http_proxy
export https_proxy=$http_proxy
curl google.com
怎么才能有这个IP地址呢,如图 V2N 客户端 config.json

或者使用 socks5tohttp 转换成 http 代理

