Skip to content

Commit

Permalink
docker: add .saltbox variant of the dns host
Browse files Browse the repository at this point in the history
  • Loading branch information
saltydk committed Dec 12, 2023
1 parent c3ec9ed commit f78eba4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion roles/docker/files/docker-update-hosts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ while read event; do
if [[ "$event" == *" container start "* ]] || [[ "$event" == *" network disconnect "* ]]; then
hosts_file_tmp="$(mktemp)"
docker container ls -q | xargs -r docker container inspect | \
jq -r '.[]|"\(.NetworkSettings.Networks[].IPAddress|select(length > 0) // "# no ip address:") \( if .NetworkSettings.Networks[].Aliases | length > 0 then .NetworkSettings.Networks[].Aliases | join(" ") |sub("^/"; "")|sub("_1$"; "")|sub("-1$"; "") else (.Name|sub("^/"; "")|sub("_1$"; "")|sub("-1$"; "")) end)"' | \
jq -r '.[] | if (.NetworkSettings.Networks[].IPAddress | length > 0) then "\(.NetworkSettings.Networks[].IPAddress) \(.NetworkSettings.Networks[].Aliases | select(length > 0) | join(" ")) \(.Name | sub("^/"; "") | sub("_1$"; "") | sub("-1$"; "")).saltbox" else "# no ip address: \(.Name | sub("^/"; ""))" end' | \
sed -ne "/^${begin_block}$/ {p; r /dev/stdin" -e ":a; n; /^${end_block}$/ {p; b}; ba}; p" "$hosts_file" \
> "$hosts_file_tmp"
chmod 644 "$hosts_file_tmp"
Expand Down

0 comments on commit f78eba4

Please sign in to comment.