Coder Social home page Coder Social logo

dockerproxymanager's Introduction

DockerProxyManager

用于快捷的 开启/关闭 docker的网络代理 官方文档

  1. 安装方法
  • 从realse下载二进制文件 或 自行编译

  • 放入/usr/local/bin文件夹下 (windwos 耗子尾汁)

    • wget xxx
      sudo cp xxx /usr/local/bin/DPM
      sudo chmod +X /usr/local/bin/DPM
  1. 使用教程(建议配置alias)
❯ dpm -h

Usage of dpm:
  -httpProxy string
        HTTP代理地址。 (default "http://127.0.0.1:7890")
  -httpsProxy string
        HTTPS代理地址。 (default "http://127.0.0.1:7890")
  -noProxy string
        无代理设置。 (default "localhost,127.0.0.1,.daocloud.io")
  -onProxy int
        代理设置 0: 关闭,1: 开启 (default -1)
  • 开启代理
######## 开启代理

❯ dpm -onProxy 1
配置如下:Proxy 1                                                                                                                                                                                                                                                 ─╯
httpProxy: http://127.0.0.1:7890
httpsProxy: http://127.0.0.1:7890
noProxy: localhost,127.0.0.1,.daocloud.io
代理开关: 开启

/Users/zeke/.docker/config.json 原始内容
{
  "auths": {},
  "credsStore": "desktop",
  "currentContext": "desktop-linux"
}

/Users/zeke/.docker/config.json 修改后内容
{
  "auths": {},
  "credsStore": "desktop",
  "currentContext": "desktop-linux",
  "proxies": {
    "default": {
      "httpProxy": "http://127.0.0.1:7890",
      "httpsProxy": "http://127.0.0.1:7890",
      "noProxy": "localhost,127.0.0.1,.daocloud.io"
    }
  }
}% 
  • 关闭代理
######## 关闭代理
❯ dpm -onProxy 0
配置如下:Proxy 0                                                                                                                                                                                                                                                 ─╯
httpProxy: http://127.0.0.1:7890
httpsProxy: http://127.0.0.1:7890
noProxy: localhost,127.0.0.1,.daocloud.io
代理开关: 关闭

/Users/zeke/.docker/config.json 原始内容
{
  "auths": {},
  "credsStore": "desktop",
  "currentContext": "desktop-linux"
}

/Users/zeke/.docker/config.json 修改后内容
{
  "auths": {},
  "credsStore": "desktop",
  "currentContext": "desktop-linux"
}%                                                                                                                                                                                                                                                                  
  • 配置httpProxy等地址
❯ dpm -httpProxy http://192.155.1.93:37890 \
        -httpsProxy http://192.155.1.93:37890 \
        -noProxy localhost \
        -onProxy  1
配置如下:
httpProxy: http://192.155.1.93:37890
httpsProxy: http://192.155.1.93:37890
noProxy: localhost
代理开关: 开启

/Users/zeke/.docker/config.json 原始内容
{
  "auths": {},
  "credsStore": "desktop",
  "currentContext": "desktop-linux",
  "proxies": {
    "default": {
      "httpProxy": "http://127.0.0.1:7890",
      "httpsProxy": "http://127.0.0.1:7890",
      "noProxy": "localhost,127.0.0.1,.daocloud.io"
    }
  }
}

/Users/zeke/.docker/config.json 修改后内容
{
  "auths": {},
  "credsStore": "desktop",
  "currentContext": "desktop-linux",
  "proxies": {
    "default": {
      "httpProxy": "http://192.155.1.93:37890",
      "httpsProxy": "http://192.155.1.93:37890",
      "noProxy": "localhost"
    }
  }
}%                               
  1. 配置alias 将以下内容写进你的~/.bashrc~/.zshrc
# Define the variable
http_proxy="http://127.0.0.1:7890"
https_proxy="http://127.0.0.1:7890"
alias dpon="DPM -httpProxy $http_proxy -httpsProxy $http_proxy -onProxy 1"
alias dpoff="DPM -onProxy 0"

执行source ~/.bashrcsource ~/.zshrc即可

然后你就可以使用dpondpoff来开启和关闭docker的代理了

  1. 备份文件夹 每次更新配置文件~/.docker/config.json前 都会备份到~/.docker/config_back文件夹中,最多保留5个

dockerproxymanager's People

Watchers

zeke avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.