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"
21
21
# separate multiple with pipes "|"
22
22
export APP_CONTAINER_SUFFIXES="app|php"
23
23
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
+
24
29
# this will attach to the docker logs of the proxy containers after executing
25
30
# `DockerExec proxy init` if set to 1
26
31
export ATTACH_TO_COMPOSE_LOGS=1
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ export LINUX_HOSTS=/etc/hosts
14
14
export STATUS_FILE_NAME=" docker_current.txt"
15
15
export TEMP_HOSTS_FILE=" .current-hosts"
16
16
export UPD_FILE_NAME=" .last-update"
17
+ export IGNORED_HOSTS_CONTAINERS=" ${IGNORED_HOSTS_CONTAINERS:- } "
17
18
18
19
export SRC_DIR=" $BASE_DIR /src"
19
20
export PROXY_ENV_FILE=" $BASE_DIR /.env"
@@ -246,7 +247,7 @@ elif [[ "proxy" == "$ENVIRONMENT" ]]; then
246
247
start_spawn_container " $file "
247
248
done
248
249
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
250
251
update_host_files_with_proxy
251
252
publish_host_files " APP"
252
253
Original file line number Diff line number Diff line change @@ -283,6 +283,7 @@ function update_host_files_with_proxy() {
283
283
# update the /etc/hosts file in any proxy related container with data from .current-hosts file
284
284
function publish_host_files() {
285
285
local HOST_CONTAINER_SUFFIXES=($( echo " $1 " | tr " |" " \n" ) )
286
+ local IGNORED_CONTAINERS=($( echo " $IGNORED_HOSTS_CONTAINERS " | tr " |" " \n" ) )
286
287
local FORMATTED_CONTAINERS=
287
288
288
289
for NEXT_SUFFIX in " ${HOST_CONTAINER_SUFFIXES[@]} " ; do
@@ -296,7 +297,7 @@ function publish_host_files() {
296
297
PROXY_CONTAINERS=$( docker ps -a --format ' {{ .Names }}' -f status=' running' -f name=' proxy-' )
297
298
298
299
while read -r CURRENT; do
299
- if [[ -n " $CURRENT " ]]; then
300
+ if [[ -n " $CURRENT " && ! " ${IGNORED_CONTAINERS[*]} " =~ " $CURRENT " ]]; then
300
301
CURRENT_CONTENT=$( docker exec -u root " $CURRENT " /bin/sh -c " cat /etc/hosts" )
301
302
CURRENT_CONTENT=$( echo " $CURRENT_CONTENT " | sed ' /^### DockerExec hosts file update ###/,$d' )
302
303
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