Skip to content

Instantly share code, notes, and snippets.

@link89
Created February 4, 2024 07:41
Show Gist options
  • Save link89/eca025b744e310b9d383e0a3995425cb to your computer and use it in GitHub Desktop.
Save link89/eca025b744e310b9d383e0a3995425cb to your computer and use it in GitHub Desktop.
Essential network tips for China developer.

Docker

set proxy for docker build and docker run

You can add proxy configurations for the Docker client using a JSON configuration file, located in ~/.docker/config.json. Builds and containers use the configuration specified in this file.

{
 "proxies": {
   "default": {
     "httpProxy": "http://proxy.example.com:3128",
     "httpsProxy": "https://proxy.example.com:3129",
     "noProxy": "*.test.example.com,.example.org,127.0.0.0/8"
   }
 }
}

Refs

Access hostnetwork inside docker container

Use host.docker.internal instead of localhost, for Linux an extra option is required: --add-host=host.docker.internal:host-gateway

Or use 172.17.0.1 instead of 127.0.0.1

Refs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment