Vonng / pigsty

Battery-Included PostgreSQL Distro as a Free RDS Alternative
https://pigsty.io
GNU Affero General Public License v3.0
2.97k stars 241 forks source link

write `proxy_env` to docker daemon.json if applicable #426

Closed Vonng closed 4 days ago

Vonng commented 2 weeks ago

Since docker hub is banned in China... We'll have proxy env for docker daemon.

Vonng commented 2 weeks ago

The rough idea is using a new daemon.json template like:

{
  "exec-opts": ["native.cgroupdriver={{ docker_cgroups_driver }}"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2",
  "metrics-addr" : "{{ inventory_hostname }}:9323",
  "experimental" : true,
{% if proxy_env is defined and proxy_env is mapping %}
  "proxies": {
{% if 'http_proxy' in proxy_env %}
    "http-proxy": "{{ proxy_env['http_proxy'] }}",
{% elif 'all_proxy' in proxy_env %}
    "http-proxy": "{{ proxy_env['all_proxy'] }}",
{% endif %}
{% if 'https_proxy' in proxy_env %}
    "https-proxy": "{{ proxy_env['http_proxy'] }}",
{% elif 'all_proxy' in proxy_env %}
    "https-proxy": "{{ proxy_env['all_proxy'] }}",
{% endif %}
{% if 'no_proxy' in proxy_env %}
    "no-proxy": "{{ proxy_env['no_proxy'] }}"
{% else %}
    "no-proxy": "localhost,127.0.0.1,10.0.0.0/8,192.168.0.0/16,*.pigsty"
{% endif %}
  },
{% endif %}

  "registry-mirrors" : {{ docker_registry_mirrors | to_json }}
}
Vonng commented 4 days ago

resolved by https://github.com/Vonng/pigsty/commit/afadf29d056f1e0e8d754536178a17ab17ce112a