修改 /etc/init.d/dockerd
使用 procd_set_param env
設定環境變數
原指令碼:
start_service() { local nofile=$(cat /proc/sys/fs/nr_open) process_config procd_open_instance procd_set_param stderr 1 if [ -z "${DOCKERD_CONF}" ]; then procd_set_param command /usr/bin/dockerd else procd_set_param command /usr/bin/dockerd --config-file="${DOCKERD_CONF}" fi procd_set_param limits nofile="${nofile} ${nofile}" procd_close_instance }
新指令碼:
start_service() { local nofile=$(cat /proc/sys/fs/nr_open) process_config procd_open_instance # set proxy procd_set_param env HTTP_PROXY=http://192.168.100.54:7890 procd_set_param env HTTPS_PROXY=http://192.168.100.54:7890 procd_set_param stderr 1 if [ -z "${DOCKERD_CONF}" ]; then procd_set_param command /usr/bin/dockerd else procd_set_param command /usr/bin/dockerd --config-file="${DOCKERD_CONF}" fi procd_set_param limits nofile="${nofile} ${nofile}" procd_close_instance }
新增了紅色部分
參考連結:https://loveyu.org/6115.html