Last active
October 18, 2022 07:36
-
-
Save duruyao/2423be0d22dfca2f3735187bc56616ae to your computer and use it in GitHub Desktop.
Enable or disable proxy for Docker.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
## date: 2022-01-19 | |
## author: duruyao@gmail.com | |
## desc: disable proxy for docker | |
## usage: docker-proxy-close | |
rm -f "${HOME}/.docker/config.json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
## date: 2022-01-19 | |
## author: duruyao@gmail.com | |
## desc: enable proxy for docker | |
## usage: docker-proxy-open [PROXY_IP:PROXY_PORT] | |
proxy_addr="172.10.0.1:7890" | |
if [ $# -gt 0 ]; then | |
proxy_addr="$1" | |
fi | |
mkdir -p "${HOME}/.docker" | |
echo "{ | |
\"proxies\": | |
{ | |
\"default\": | |
{ | |
\"httpProxy\": \"http://${proxy_addr}\", | |
\"httpsProxy\": \"http://${proxy_addr}\", | |
\"noProxy\": \"localhost,127.0.0.0/8,::1\" | |
} | |
} | |
}" >"${HOME}/.docker/config.json" | |
cat "${HOME}/.docker/config.json" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment