关于docker:docker使用代理in-home

38次阅读

共计 826 个字符,预计需要花费 3 分钟才能阅读完成。

docker 应用 http http_proxy

https://docs.docker.com/config/daemon/systemd/

# 代理 和  国内 镜像源 不要 同时应用,。。。# "storage-driver":   "overlay2",


apt install docker.io -y


proxy_url='192.168.10.20:7890'

mkdir -p /etc/systemd/system/docker.service.d
cat > /etc/systemd/system/docker.service.d/http-proxy.conf <<EOF
[Service]
Environment="HTTP_PROXY=http://${proxy_url}"
Environment="HTTPS_PROXY=http://${proxy_url}"
EOF


self_hub='192.168.10.101:5000'


cat > /etc/docker/daemon.json <<EOF
{
    "bip":"10.199.123.1/24",
    "log-level":        "error",
    "insecure-registries": ["${self_hub}"]
}
EOF

systemctl enable docker
systemctl daemon-reload
systemctl restart docker

推送到 本人的 镜像仓库

self_hub='192.168.71.1:5000'

function tag_img_and_push(){docker tag ${1} ${self_hub}/${1}
    docker push  ${self_hub}/${1}
}

for i in $(docker images | grep -v 'TAG' | awk '{print $1":"$2}' | grep -v "${self_hub}" | grep -v '192.168'  )
do
   tag_img_and_push ${i} &
done

wait

正文完
 0