This seems to work, Ubuntu is hoarding port 53 though even though local services are shut off.
This commit is contained in:
@@ -6,15 +6,16 @@
|
|||||||
|
|
||||||
FROM debian
|
FROM debian
|
||||||
|
|
||||||
|
# Remove Existing Config
|
||||||
|
RUN rm -rfv /etc/{hosts,resolv.conf,dnsmasq.conf}
|
||||||
|
|
||||||
# Install Dependencies
|
# Install Dependencies
|
||||||
RUN apt update && apt install -y dnsmasq
|
RUN apt update && apt install -y dnsmasq
|
||||||
|
|
||||||
# Remove Existing Config
|
|
||||||
RUN systemctl stop dnsmasq
|
|
||||||
RUN rm -rfv /etc/{hosts,resolv.conf,dnsmasq.conf}
|
|
||||||
|
|
||||||
# Copy Configuration Files
|
# Copy Configuration Files
|
||||||
COPY ./config/{hosts,resolv.conf,dnsmasq.conf} /etc/
|
COPY ./config/hosts /etc/
|
||||||
|
COPY ./config/resolv.conf /etc/
|
||||||
|
COPY ./config/dnsmasq.conf /etc/
|
||||||
|
|
||||||
# Start Container
|
## Reload Service
|
||||||
CMD systemctl restart dnsmasq
|
RUN service dnsmasq restart
|
||||||
|
@@ -10,6 +10,14 @@ version: '3'
|
|||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
build: ./
|
build: ./
|
||||||
restart: always
|
restart: on-failure
|
||||||
ports:
|
ports:
|
||||||
- "53:53"
|
- "53:53"
|
||||||
|
command: |
|
||||||
|
/bin/sh -c '
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
sleep 8h & wait $${!}
|
||||||
|
service dnsmasq restart
|
||||||
|
done
|
||||||
|
'
|
||||||
|
47
Config/DNS/run.sh
Executable file
47
Config/DNS/run.sh
Executable file
@@ -0,0 +1,47 @@
|
|||||||
|
# 2023-07-29
|
||||||
|
# Config/DNS/run.sh
|
||||||
|
# Fix common issues when trying to run this container.
|
||||||
|
|
||||||
|
function stop-service {
|
||||||
|
service=""
|
||||||
|
if [[ -n $1 ]]; then
|
||||||
|
service=$1
|
||||||
|
else
|
||||||
|
echo "ERROR: A parameter was not provided for stop-service, aborting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ -n $2 ]]; then
|
||||||
|
echo "ERROR: A second parameter to stop-service is not expected, aborting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
systemctl disable --now $service &&
|
||||||
|
echo "$service stopped successfully!" ||
|
||||||
|
echo "$service was not found, no problem."
|
||||||
|
}
|
||||||
|
|
||||||
|
echo -e "\n*** Turn off any local DNS programs ***"
|
||||||
|
# These programs use port 53 but this container needs to be able to listen on it.
|
||||||
|
stop-service systemd-resolved
|
||||||
|
stop-service dnsmasq
|
||||||
|
|
||||||
|
echo -e "\n*** Create a working DNS file ***"
|
||||||
|
# Allows the domains needed during the docker pull/build to be accessed.
|
||||||
|
if [[ ! -e /etc/resolv.conf.save ]]; then
|
||||||
|
# Save the existing file if a backup does not already exist.
|
||||||
|
mv /etc/resolv.conf /etc/resolv.conf.save
|
||||||
|
fi
|
||||||
|
echo "nameserver 1.1.1.1" > /etc/resolv.conf
|
||||||
|
|
||||||
|
echo -e "\n*** Start the docker container ***"
|
||||||
|
docker compose down
|
||||||
|
docker compose build
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
|
echo -e "\n*** Now use the local process for DNS ***\n/etc/resolv.conf:"
|
||||||
|
echo "nameserver 127.0.0.1" > /etc/resolv.conf
|
||||||
|
echo "nameserver 127.0.1.1" >> /etc/resolv.conf
|
||||||
|
cat /etc/resolv.conf
|
||||||
|
|
||||||
|
# Finish
|
||||||
|
echo " "
|
||||||
|
exit 0
|
44
Config/DNS/undo.sh
Executable file
44
Config/DNS/undo.sh
Executable file
@@ -0,0 +1,44 @@
|
|||||||
|
# 2023-07-29
|
||||||
|
# Config/DNS/undo.sh
|
||||||
|
# Easy way to stop using this container.
|
||||||
|
|
||||||
|
function start-service {
|
||||||
|
service=""
|
||||||
|
if [[ -n $1 ]]; then
|
||||||
|
service=$1
|
||||||
|
else
|
||||||
|
echo "ERROR: A parameter was not provided for start-service, aborting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ -n $2 ]]; then
|
||||||
|
echo "ERROR: A second parameter to start-service is not expected, aborting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
systemctl enable --now $service &&
|
||||||
|
echo "$service started successfully!" ||
|
||||||
|
echo "$service was not found, no problem."
|
||||||
|
}
|
||||||
|
|
||||||
|
echo -e "\n*** Stop the docker container ***"
|
||||||
|
docker compose down
|
||||||
|
|
||||||
|
echo -en "\n*** Restore the DNS file "
|
||||||
|
if [[ -e /etc/resolv.conf.save ]]; then
|
||||||
|
echo "from backup ***"
|
||||||
|
cp /etc/resolv.conf.save /etc/resolv.conf
|
||||||
|
else
|
||||||
|
echo "with Cloudflare ***"
|
||||||
|
echo "nameserver 1.1.1.1" > /etc/resolv.conf
|
||||||
|
echo "nameserver 1.0.0.1" >> /etc/resolv.conf
|
||||||
|
echo "options rotate" >> /etc/resolv.conf
|
||||||
|
fi
|
||||||
|
echo "/etc/resolv.conf:"
|
||||||
|
cat /etc/resolv.conf
|
||||||
|
|
||||||
|
echo -e "\n*** Turn on any local DNS programs ***"
|
||||||
|
start-service systemd-resolved
|
||||||
|
start-service dnsmasq
|
||||||
|
|
||||||
|
# Finish
|
||||||
|
echo " "
|
||||||
|
exit 0
|
Reference in New Issue
Block a user