Skip to content

Commit 815d21e

Browse files
authored
fix, breaking: remove explicitly set container names to avoid name conflict (#10)
- not setting `container-name` attribute resolves the name conflict on rebuilding/re-deploying - breaking: rename project to shorter name `ns`, now independent of the local git repo folder name this means for `docker exec`, the container name changes to e.g.: `ns-pihole-1` - breaking: move pihole's mapped container to `~/etc-pihole`, no longer part of the repo to preserve state, move the repo-local folder: `mv ./pihole ~/etc-pihole` - adding a `./deploy.sh` script to make deployments consistent and easier if e.g. sudo is required on docker host - fixes #9
1 parent ffc582f commit 815d21e

File tree

4 files changed

+27
-18
lines changed

4 files changed

+27
-18
lines changed

.github/workflows/CI.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ jobs:
4242
echo "-- List containers:"
4343
docker ps --size
4444
echo "-- traefik logs:"
45-
docker logs traefik
45+
docker logs ns-traefik-1
4646
echo "-- unbound logs:"
47-
docker logs dns
47+
docker logs ns-dns-1
4848
echo "-- pihole logs:"
49-
docker logs pihole
49+
docker logs ns-pihole-1
5050
5151
- name: Test Unbound DNS resolution
5252
env:
@@ -58,9 +58,9 @@ jobs:
5858
echo "-- Sleeping..."
5959
sleep 10
6060
echo "-- Unbound stats:"
61-
docker exec -i dns unbound-control stats_noreset
61+
docker exec -i ns-dns-1 unbound-control stats_noreset
6262
echo "-- Unbound cache dump:"
63-
docker exec -i dns unbound-control dump_cache > $DUMP_CACHE_FILE
63+
docker exec -i ns-dns-1 unbound-control dump_cache > $DUMP_CACHE_FILE
6464
cat $DUMP_CACHE_FILE | head -n 10
6565
echo "-- Unbound cache dump (last 10 lines):"
6666
tail -n 10 $DUMP_CACHE_FILE
@@ -70,9 +70,9 @@ jobs:
7070
echo "-- DNSSEC query:"
7171
dig -p 5300 @localhost microsoft.com +dnssec
7272
echo "-- pihole log:"
73-
docker exec -i pihole tail -40 /var/log/pihole/pihole.log | tee $ARTIFACT_DIR/pihole.log
73+
docker exec -i ns-pihole-1 tail -40 /var/log/pihole/pihole.log | tee $ARTIFACT_DIR/pihole.log
7474
echo "-- pihole log:"
75-
docker exec -i pihole tail -40 /var/log/pihole/FTL.log | tee $ARTIFACT_DIR/FTL.log
75+
docker exec -i ns-pihole-1 tail -40 /var/log/pihole/FTL.log | tee $ARTIFACT_DIR/FTL.log
7676
7777
- name: Stop containers
7878
run: |

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,19 @@ dig -p 5300 @localhost cloudflare.com +dnssec
3434
directly connect to container:
3535

3636
```bash
37-
docker exec -it dns ash
37+
docker exec -it ns-dns-1 ash
3838
```
3939

4040
## Deployment
4141

4242
### Manual deployment
4343

44-
- git clone this repo (or [download main branch as zip, then unzip](https://github.com/davidjenni/pi-hole-unbound/archive/refs/heads/main.zip))
44+
- git clone this repo (or [download latest release as zip, then unzip](https://github.com/davidjenni/pi-hole-unbound/releases))
4545
- Create your own *.prod.env file, use the checked in jenni.prod.env as starting point
4646
- re-start compose stack (build & pull before stopping the already running DNS server!):
4747

4848
```bash
49-
docker compose --env-file lan.prod.env build --pull && \
50-
docker compose --env-file lan.prod.env stop && \
51-
docker compose --env-file lan.prod.env up -d --wait && \
52-
docker compose ps
49+
./deploy.sh
5350
```
5451

5552
## TODOs

compose.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
name: ns
2+
13
services:
24
traefik:
3-
container_name: traefik
45
image: traefik:v3.4
56
command:
67
- "--api.insecure=true"
@@ -32,7 +33,6 @@ services:
3233
- "traefik.enable=true"
3334

3435
dns:
35-
container_name: dns
3636
build:
3737
context: ./unbound/
3838
dockerfile: Dockerfile
@@ -51,7 +51,6 @@ services:
5151
restart: unless-stopped
5252

5353
pihole:
54-
container_name: pihole
5554
hostname: $PIHOLE_HOSTNAME
5655
image: pihole/pihole:latest
5756
networks:
@@ -69,9 +68,9 @@ services:
6968
FTLCONF_dns_reply_host_force4: "true"
7069
FTLCONF_webserver_paths_prefix: "/pihole"
7170
# set webUI password later via:
72-
# > docker exec -it pihole pihole setpassword <password>
71+
# > docker exec -it ns-pihole-1 pihole setpassword <password>
7372
volumes:
74-
- ./pi-hole:/etc/pihole
73+
- ~/etc-pihole:/etc/pihole
7574
labels:
7675
- "traefik.enable=true"
7776
- "traefik.http.routers.pihole.entrypoints=web"

deploy.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
echo ">>-- Current running containers:" && \
3+
docker container ls && \
4+
echo ">>-- Building and pulling latest images..." && \
5+
docker compose --env-file lan.prod.env pull && \
6+
docker compose --env-file lan.prod.env build && \
7+
echo ">>-- Deploying new versions..." && \
8+
docker compose --env-file lan.prod.env stop && \
9+
docker compose --env-file lan.prod.env up -d --wait && \
10+
echo ">>-- Deployment complete. Current containers:" && \
11+
docker container ls -a && \
12+
echo ">>-- Current container stats:" && \
13+
docker compose --env-file lan.prod.env stats --no-stream

0 commit comments

Comments
 (0)