Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logs mention containers registered. dig still fails to return records for them. #40

Open
jmdots opened this issue May 26, 2024 · 0 comments

Comments

@jmdots
Copy link

jmdots commented May 26, 2024

Could you help me figure out where I went wrong?

(base) josh@monolith-1:~$ dig @127.0.0.1 -p 15353 caddy.docker

; <<>> DiG 9.18.18-0ubuntu0.22.04.2-Ubuntu <<>> @127.0.0.1 -p 15353 caddy.docker
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 34602
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;caddy.docker.			IN	A

;; AUTHORITY SECTION:
.			599	IN	SOA	a.root-servers.net. nstld.verisign-grs.com. 2024052602 1800 900 604800 86400

;; Query time: 95 msec
;; SERVER: 127.0.0.1#15353(127.0.0.1) (UDP)
;; WHEN: Sun May 26 17:22:32 EDT 2024
;; MSG SIZE  rcvd: 116

(base) josh@monolith-1:~$ dig @127.0.0.1 -p 15353 caddy.docker.loc

; <<>> DiG 9.18.18-0ubuntu0.22.04.2-Ubuntu <<>> @127.0.0.1 -p 15353 caddy.docker.loc
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 835
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;caddy.docker.loc.		IN	A

;; AUTHORITY SECTION:
.			599	IN	SOA	a.root-servers.net. nstld.verisign-grs.com. 2024052602 1800 900 604800 86400

;; Query time: 91 msec
;; SERVER: 127.0.0.1#15353(127.0.0.1) (UDP)
;; WHEN: Sun May 26 17:22:56 EDT 2024
;; MSG SIZE  rcvd: 120

(base) josh@monolith-1:~$ dig @127.0.0.1 -p 15353 caddy.docker-host.loc

; <<>> DiG 9.18.18-0ubuntu0.22.04.2-Ubuntu <<>> @127.0.0.1 -p 15353 caddy.docker-host.loc
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 53881
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;caddy.docker-host.loc.		IN	A

;; AUTHORITY SECTION:
.			599	IN	SOA	a.root-servers.net. nstld.verisign-grs.com. 2024052602 1800 900 604800 86400

;; Query time: 99 msec
;; SERVER: 127.0.0.1#15353(127.0.0.1) (UDP)
;; WHEN: Sun May 26 17:23:14 EDT 2024
;; MSG SIZE  rcvd: 125

(base) josh@monolith-1:~$ docker logs coredns 
[docker] start
.:15353 on 0.0.0.0
CoreDNS-1.11.3
linux/amd64, go1.21.10, 621ffde53-dirty
[docker] Add entry of container coredns (0ea7cd62cf0a). IP: 172.17.0.4
[docker] Add entry of container caddy (1171c37a5aa8). IP: 172.17.0.2
[docker] Add entry of container postgres (d5c42b170e49). IP: 172.18.0.4
[docker] Add entry of container namecheap-ddns-updater (88dfeb04f838). IP: 172.17.0.3
[docker] Add entry of container element (71102d723743). IP: 172.18.0.2
[INFO] 172.17.0.1:54709 - 34602 "A IN caddy.docker. udp 53 false 1232" NXDOMAIN qr,rd,ra 116 0.095756145s
[INFO] 172.17.0.1:41537 - 835 "A IN caddy.docker.loc. udp 57 false 1232" NXDOMAIN qr,rd,ra 120 0.091373966s
[INFO] 172.17.0.1:60327 - 53881 "A IN caddy.docker-host.loc. udp 62 false 1232" NXDOMAIN qr,rd,ra 125 0.099162413s
(base) josh@monolith-1:~$ docker ps
CONTAINER ID   IMAGE                         COMMAND                  CREATED         STATUS         PORTS                                                         NAMES
0ea7cd62cf0a   custom-coredns:latest         "/coredns/coredns -c…"   2 minutes ago   Up 2 minutes   0.0.0.0:15353->15353/udp                                      coredns
1171c37a5aa8   custom-caddy:latest           "caddy run --config …"   20 hours ago    Up 10 hours    0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 443/udp, 2019/tcp   caddy
d5c42b170e49   postgres:14                   "docker-entrypoint.s…"   20 hours ago    Up 10 hours    5432/tcp                                                      postgres
88dfeb04f838   namecheap-ddns-updater        "bash -c 'while :; d…"   20 hours ago    Up 10 hours                                                                  namecheap-ddns-updater
71102d723743   vectorim/element-web:latest   "/docker-entrypoint.…"   28 hours ago    Up 10 hours    80/tcp                                                        element
(base) josh@monolith-1:~$ 
(base) josh@monolith-1:~/src/jmdots-ansible/common/docker$ docker logs coredns -f
[docker] start
.:15353 on 0.0.0.0
CoreDNS-1.11.3
linux/amd64, go1.21.10, 621ffde53-dirty
[docker] Add entry of container coredns (0ea7cd62cf0a). IP: 172.17.0.4
[docker] Add entry of container caddy (1171c37a5aa8). IP: 172.17.0.2
[docker] Add entry of container postgres (d5c42b170e49). IP: 172.18.0.4
[docker] Add entry of container namecheap-ddns-updater (88dfeb04f838). IP: 172.17.0.3
[docker] Add entry of container element (71102d723743). IP: 172.18.0.2
[INFO] 172.17.0.1:54709 - 34602 "A IN caddy.docker. udp 53 false 1232" NXDOMAIN qr,rd,ra 116 0.095756145s
[INFO] 172.17.0.1:41537 - 835 "A IN caddy.docker.loc. udp 57 false 1232" NXDOMAIN qr,rd,ra 120 0.091373966s
[INFO] 172.17.0.1:60327 - 53881 "A IN caddy.docker-host.loc. udp 62 false 1232" NXDOMAIN qr,rd,ra 125 0.099162413s
(base) josh@monolith-1:~/src/jmdots-ansible/common/docker$ docker logs coredns -f
[docker] start
.:15353 on 0.0.0.0
CoreDNS-1.11.3
linux/amd64, go1.21.10, 621ffde53-dirty
[docker] Add entry of container coredns (0ea7cd62cf0a). IP: 172.17.0.4
[docker] Add entry of container caddy (1171c37a5aa8). IP: 172.17.0.2
[docker] Add entry of container postgres (d5c42b170e49). IP: 172.18.0.4
[docker] Add entry of container namecheap-ddns-updater (88dfeb04f838). IP: 172.17.0.3
[docker] Add entry of container element (71102d723743). IP: 172.18.0.2
[INFO] 172.17.0.1:54709 - 34602 "A IN caddy.docker. udp 53 false 1232" NXDOMAIN qr,rd,ra 116 0.095756145s
[INFO] 172.17.0.1:41537 - 835 "A IN caddy.docker.loc. udp 57 false 1232" NXDOMAIN qr,rd,ra 120 0.091373966s
[INFO] 172.17.0.1:60327 - 53881 "A IN caddy.docker-host.loc. udp 62 false 1232" NXDOMAIN qr,rd,ra 125 0.099162413s
^C
(base) josh@monolith-1:~/src/jmdots-ansible/common/docker$ cat var/coredns-build/
Corefile    Dockerfile  
(base) josh@monolith-1:~/src/jmdots-ansible/common/docker$ cat var/coredns-build/Corefile 
.:15353 {
    bind 0.0.0.0
    docker unix:///var/run/docker.sock {
        ttl 30
        domain docker.loc
        hostname_domain docker-host.loc
    }
    log
    errors
    forward . 8.8.8.8 8.8.4.4
}
(base) josh@monolith-1:~/src/jmdots-ansible/common/docker$ cat var/coredns-build/Dockerfile 
# Stage 1: Build CoreDNS with Docker plugin
FROM golang:1.21-alpine AS build

# Install necessary build tools
RUN apk add --no-cache git make

# Set up working directory
WORKDIR /go/src/github.com/coredns/coredns

# Clone the CoreDNS repository
RUN git clone https://github.com/coredns/coredns.git .

# Add the Docker plugin to plugin.cfg
RUN echo "docker:github.com/kevinjqiu/coredns-dockerdiscovery" >> plugin.cfg

# Ensure no duplicate entries in plugin.cfg
RUN cat plugin.cfg | uniq > plugin.cfg.tmp && mv plugin.cfg.tmp plugin.cfg

# Fetch Go modules
RUN go mod tidy

# Build CoreDNS
RUN make

# Stage 2: Create the final image
FROM alpine:latest

# Set up working directory
WORKDIR /coredns

# Copy the built CoreDNS binary
COPY --from=build /go/src/github.com/coredns/coredns/coredns /coredns/coredns

# Copy the Corefile
COPY Corefile /coredns/Corefile

# Expose DNS ports
EXPOSE 15353/udp

# Command to run CoreDNS
CMD ["/coredns/coredns", "-conf", "/coredns/Corefile"]
(base) josh@monolith-1:~/src/jmdots-ansible/common/docker$ 

Edit:

(base) josh@monolith-1:~$ dig @127.0.0.1 -p 15353 caddy

; <<>> DiG 9.18.18-0ubuntu0.22.04.2-Ubuntu <<>> @127.0.0.1 -p 15353 caddy
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 52825
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;caddy.				IN	A

;; Query time: 0 msec
;; SERVER: 127.0.0.1#15353(127.0.0.1) (UDP)
;; WHEN: Sun May 26 17:26:56 EDT 2024
;; MSG SIZE  rcvd: 34

(base) josh@monolith-1:~$ 

Second edit, to show me folllowing readme verbatim (--hostname)

(base) josh@monolith-1:~$ docker run -d --name my-alpine --hostname alpine alpine sleep 1000
Unable to find image 'alpine:latest' locally
latest: Pulling from library/alpine
d25f557d7f31: Already exists 
Digest: sha256:77726ef6b57ddf65bb551896826ec38bc3e53f75cdde31354fbffb4f25238ebd
Status: Downloaded newer image for alpine:latest
288dcc77b7f64dd5972402d42969864f197290244f918c915bfb0491443dcf5e
(base) josh@monolith-1:~$ docker ps
CONTAINER ID   IMAGE                         COMMAND                  CREATED         STATUS         PORTS                                                         NAMES
288dcc77b7f6   alpine                        "sleep 1000"             5 seconds ago   Up 4 seconds                                                                 my-alpine
0ea7cd62cf0a   custom-coredns:latest         "/coredns/coredns -c…"   8 minutes ago   Up 8 minutes   0.0.0.0:15353->15353/udp                                      coredns
1171c37a5aa8   custom-caddy:latest           "caddy run --config …"   20 hours ago    Up 10 hours    0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 443/udp, 2019/tcp   caddy
d5c42b170e49   postgres:14                   "docker-entrypoint.s…"   20 hours ago    Up 10 hours    5432/tcp                                                      postgres
88dfeb04f838   namecheap-ddns-updater        "bash -c 'while :; d…"   20 hours ago    Up 10 hours                                                                  namecheap-ddns-updater
71102d723743   vectorim/element-web:latest   "/docker-entrypoint.…"   28 hours ago    Up 10 hours    80/tcp                                                        element
(base) josh@monolith-1:~$ 78c2a06ef2a9b63df857b7985468f7310bba0d9ea4d0d2629343aff4fd171861^C
(base) josh@monolith-1:~$ dig @localhost -p 15353 my-alpine.docker.loc

; <<>> DiG 9.18.18-0ubuntu0.22.04.2-Ubuntu <<>> @localhost -p 15353 my-alpine.docker.loc
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 30514
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;my-alpine.docker.loc.		IN	A

;; AUTHORITY SECTION:
.			599	IN	SOA	a.root-servers.net. nstld.verisign-grs.com. 2024052602 1800 900 604800 86400

;; Query time: 35 msec
;; SERVER: 127.0.0.1#15353(localhost) (UDP)
;; WHEN: Sun May 26 17:30:42 EDT 2024
;; MSG SIZE  rcvd: 124

(base) josh@monolith-1:~$ 
(base) josh@monolith-1:~$ dig @localhost -p 15353 alpine.docker-host.loc

; <<>> DiG 9.18.18-0ubuntu0.22.04.2-Ubuntu <<>> @localhost -p 15353 alpine.docker-host.loc
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 2258
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;alpine.docker-host.loc.		IN	A

;; AUTHORITY SECTION:
.			599	IN	SOA	a.root-servers.net. nstld.verisign-grs.com. 2024052602 1800 900 604800 86400

;; Query time: 91 msec
;; SERVER: 127.0.0.1#15353(localhost) (UDP)
;; WHEN: Sun May 26 17:32:55 EDT 2024
;; MSG SIZE  rcvd: 126

(base) josh@monolith-1:~$ 

Another edit to show what network the containers are on:

(base) josh@monolith-1:~/src/jmdots-ansible/common/docker$ ./containers_vs_networks.sh 
CONTAINER ID  NAME                    NETWORK NAMES
fd2e5d7eed97  postgres                bridge
0ea7cd62cf0a  coredns                 bridge
1171c37a5aa8  caddy                   bridge
88dfeb04f838  namecheap-ddns-updater  bridge
e434dcd864b4  synapse                 bridge,matrix_net
71102d723743  element                 bridge,matrix_net
(base) josh@monolith-1:~/src/jmdots-ansible/common/docker$ 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant