docker-alpine icon indicating copy to clipboard operation
docker-alpine copied to clipboard

Nslookup doesn't work in github actions

Open taoberquer opened this issue 2 years ago • 3 comments

Hi, I'm trying to access a database from a container with nslookup and I'm getting an error. I've made an example of my github actions to reproduce the error. If I've forgotten anything, please let me know.

The error :

Run nslookup postgres
  
Server:		127.0.0.11
Address:	127.0.0.11:53

** server can't find postgres.psu1waqqpzqu3mj[4](https://github.com/sedeotech/inferni/actions/runs/6588514445/job/17900939871#step:3:4)5gsqnyggvb.xx.internal.cloudapp.net: NXDOMAIN

** server can't find postgres.psu1waqqpzqu3mj[4](https://github.com/sedeotech/inferni/actions/runs/6588514445/job/17900939871#step:3:5)[5](https://github.com/sedeotech/inferni/actions/runs/6588514445/job/17900939871#step:3:6)gsqnyggvb.xx.internal.cloudapp.net: NXDOMAIN

The example :

name: Test

on:
  push:
    branches: ["*"]


jobs:
  test:
    services:
      postgres:
        image: postgis/postgis:15-3.4-alpine
        env:
          POSTGRES_PASSWORD: changeme
          POSTGRES_DB: database
        ports:
          - 5432:5432
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5

    runs-on: ubuntu-latest
    container: alpine:latest
    steps:
        - run: nslookup postgres

taoberquer avatar Oct 20 '23 13:10 taoberquer

We also meet similar issues, we can’t use a hostname to connect to MongoDB. It reports a ‘server selection timeout’, but our code is okay if we change the hostname to an IP address. We found that the ‘libc6-compat-1.2.3-r5.apk’ is okay, but the ‘libc6-compat-1.2.4-r2.apk’ failed. so we rollback to alpine:3.17.2 to use ‘libc6-compat-1.2.3-r5.apk’

hongli-gao avatar Nov 30 '23 08:11 hongli-gao

Hi, I'm trying to access a database from a container with nslookup and I'm getting an error. I've made an example of my github actions to reproduce the error. If I've forgotten anything, please let me know.

The error :

Run nslookup postgres
  
Server:		127.0.0.11
Address:	127.0.0.11:53

** server can't find postgres.psu1waqqpzqu3mj[4](https://github.com/sedeotech/inferni/actions/runs/6588514445/job/17900939871#step:3:4)5gsqnyggvb.xx.internal.cloudapp.net: NXDOMAIN

** server can't find postgres.psu1waqqpzqu3mj[4](https://github.com/sedeotech/inferni/actions/runs/6588514445/job/17900939871#step:3:5)[5](https://github.com/sedeotech/inferni/actions/runs/6588514445/job/17900939871#step:3:6)gsqnyggvb.xx.internal.cloudapp.net: NXDOMAIN

The example :

name: Test

on:
  push:
    branches: ["*"]


jobs:
  test:
    services:
      postgres:
        image: postgis/postgis:15-3.4-alpine
        env:
          POSTGRES_PASSWORD: changeme
          POSTGRES_DB: database
        ports:
          - 5432:5432
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5

    runs-on: ubuntu-latest
    container: alpine:latest
    steps:
        - run: nslookup postgres

the verison of binary nslookup considered the parameter hostname postgres to not be in FQDN format, Therefore, it selected the domain name from the default search domain (the "search" directive in /etc/resolv.conf), completed the hostname to FQDN format, then performed the DNS query, finally raised the DNS querry error.

you could use the hostname with the dot suffixed ("postgres."), and nslookup does NOT complet the FQDN by using default search domain.

inter169 avatar Jan 06 '24 16:01 inter169

Hi, I'm just here to report that I just spent 2 days on debugging this issue in GitHub Actions before ending up here. 🫠 The fix as described by @inter169 worked on the first try: Doing nslookup containername resolves to the random cloudapp domain thing, while suffixing with a dot (nslookup containername.) resolves internally in Docker as expected.

linuswillner avatar Oct 02 '24 12:10 linuswillner