File tree Expand file tree Collapse file tree 3 files changed +9
-2
lines changed
Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,11 @@ export WEB_CONTAINER_SUFFIXES="web"
2121# separate multiple with pipes "|"
2222export APP_CONTAINER_SUFFIXES = " app|php"
2323
24+ # if you want to ignore some containers from getting their /etc/hosts file updated
25+ # with local adresses - e.g. DNS services or Pi-Hole - enter the container names
26+ # here and separate multiple with pipes "|"
27+ export IGNORED_HOSTS_CONTAINERS = " "
28+
2429# this will attach to the docker logs of the proxy containers after executing
2530# `DockerExec proxy init` if set to 1
2631export ATTACH_TO_COMPOSE_LOGS = 1
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ export LINUX_HOSTS=/etc/hosts
1414export STATUS_FILE_NAME=" docker_current.txt"
1515export TEMP_HOSTS_FILE=" .current-hosts"
1616export UPD_FILE_NAME=" .last-update"
17+ export IGNORED_HOSTS_CONTAINERS=" ${IGNORED_HOSTS_CONTAINERS:- } "
1718
1819export SRC_DIR=" $BASE_DIR /src"
1920export PROXY_ENV_FILE=" $BASE_DIR /.env"
@@ -246,7 +247,7 @@ elif [[ "proxy" == "$ENVIRONMENT" ]]; then
246247 start_spawn_container " $file "
247248 done
248249
249- # add all proxy containers (with there IP and hostname) to current hosts file
250+ # add all proxy containers (with their IP and hostname) to current hosts file
250251 update_host_files_with_proxy
251252 publish_host_files " APP"
252253
Original file line number Diff line number Diff line change @@ -283,6 +283,7 @@ function update_host_files_with_proxy() {
283283# update the /etc/hosts file in any proxy related container with data from .current-hosts file
284284function publish_host_files() {
285285 local HOST_CONTAINER_SUFFIXES=($( echo " $1 " | tr " |" " \n" ) )
286+ local IGNORED_CONTAINERS=($( echo " $IGNORED_HOSTS_CONTAINERS " | tr " |" " \n" ) )
286287 local FORMATTED_CONTAINERS=
287288
288289 for NEXT_SUFFIX in " ${HOST_CONTAINER_SUFFIXES[@]} " ; do
@@ -296,7 +297,7 @@ function publish_host_files() {
296297 PROXY_CONTAINERS=$( docker ps -a --format ' {{ .Names }}' -f status=' running' -f name=' proxy-' )
297298
298299 while read -r CURRENT; do
299- if [[ -n " $CURRENT " ]]; then
300+ if [[ -n " $CURRENT " && ! " ${IGNORED_CONTAINERS[*]} " =~ " $CURRENT " ]]; then
300301 CURRENT_CONTENT=$( docker exec -u root " $CURRENT " /bin/sh -c " cat /etc/hosts" )
301302 CURRENT_CONTENT=$( echo " $CURRENT_CONTENT " | sed ' /^### DockerExec hosts file update ###/,$d' )
302303 UPDATED_HOSTS=" $CURRENT_CONTENT \n### DockerExec hosts file update ###\n$( cat " $TEMP_HOSTS_PATH " ) "
You can’t perform that action at this time.
0 commit comments