From: Gerard Ryan Date: Mon, 25 Jan 2021 07:46:35 +0000 (+1000) Subject: dockerd: made registry_mirrors and hosts omittable X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=348bcb6e680ca4d66b54c56ec6b79216d71e539d;p=feed%2Fpackages.git dockerd: made registry_mirrors and hosts omittable * Moved logic out of config writing * Made default config only specify OpenWrt dictated defaults Otherwise, docker defaults can be assumed Signed-off-by: Gerard Ryan --- diff --git a/utils/dockerd/files/dockerd.init b/utils/dockerd/files/dockerd.init index c1493ba2be..1eaed6710a 100755 --- a/utils/dockerd/files/dockerd.init +++ b/utils/dockerd/files/dockerd.init @@ -136,24 +136,28 @@ process_config() { config_get data_root globals data_root "/opt/docker/" config_get log_level globals log_level "warn" config_get_bool iptables globals iptables "1" + + # Don't add these options by default + # omission == docker defaults config_get bip globals bip "" + config_get registry_mirrors globals registry_mirrors "" + config_get hosts globals hosts "" . /usr/share/libubox/jshn.sh json_init json_add_string "data-root" "${data_root}" json_add_string "log-level" "${log_level}" + json_add_boolean "iptables" "${iptables}" [ -z "${bip}" ] || json_add_string "bip" "${bip}" - json_add_array "registry-mirrors" - config_list_foreach globals registry_mirrors json_add_array_string - json_close_array - json_add_array "hosts" - config_list_foreach globals hosts json_add_array_string - json_close_array - - json_add_boolean iptables "${iptables}" - [ "${iptables}" -ne "0" ] && config_foreach iptables_add_blocking_rule firewall - + [ -z "${registry_mirrors}" ] || json_add_array "registry-mirrors" + [ -z "${registry_mirrors}" ] || config_list_foreach globals registry_mirrors json_add_array_string + [ -z "${registry_mirrors}" ] || json_close_array + [ -z "${hosts}" ] || json_add_array "hosts" + [ -z "${hosts}" ] || config_list_foreach globals hosts json_add_array_string + [ -z "${hosts}" ] || json_close_array json_dump > "${DOCKERD_CONF}" + + [ "${iptables}" -eq "1" ] && config_foreach iptables_add_blocking_rule firewall } start_service() { diff --git a/utils/dockerd/files/etc/config/dockerd b/utils/dockerd/files/etc/config/dockerd index aad1dbb704..6ba850bde4 100644 --- a/utils/dockerd/files/etc/config/dockerd +++ b/utils/dockerd/files/etc/config/dockerd @@ -8,9 +8,9 @@ config globals 'globals' # option alt_config_file '/etc/docker/daemon.json' option data_root '/opt/docker/' option log_level 'warn' - list hosts 'unix:///var/run/docker.sock' - option bip '172.18.0.1/24' -# option iptables '0' + option iptables '1' +# list hosts 'unix:///var/run/docker.sock' +# option bip '172.18.0.1/24' # list registry_mirrors 'https://' # list registry_mirrors 'https://hub.docker.com'