Skip to content

[Bug]: whois failing #46

@mszczepanczyk

Description

@mszczepanczyk

Environment

Docker (self-hosted)

Version

latest

Describe the Issue

Whois is failing in a newly created docker container:

Nov 20 08:30:21 homelab docker-domain-locker-start[2794744]: 🔴 [whois] whois-json failed for google.com: getaddrinfo EAI_AGAIN whois.markmonitor.com

I checked the console whois command from inside the docker container and it works perfectly well, while the whois npm package (on which whois-json depends) fails:

/app # cat tmp.cjs 
var whois = require('whois')
whois.lookup('google.com', function(err, data) {
        if (err) {
                console.error(err);
        }
        console.log(data)
})
/app # node tmp.cjs 
Error: getaddrinfo EAI_AGAIN whois.markmonitor.com
    at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:118:26) {
  errno: -3001,
  code: 'EAI_AGAIN',
  syscall: 'getaddrinfo',
  hostname: 'whois.markmonitor.com'
}
undefined

I did some investigation and found it's a notoriously common problem with alpine. For instance, see this issue: nodejs/docker-node#1030

An easy fix is to change the underlying docker image from alpine to debian, like this (I've verified this works):

diff --git a/Dockerfile b/Dockerfile
index 49f3828..06f8a4c 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,5 @@
 # Stage 1 - build: Compiles the frontend and API code
-FROM node:20.12.0-alpine AS builder
+FROM node:20.12.0-slim AS builder

 # Set working directory
 WORKDIR /app
@@ -24,14 +24,14 @@ ENV NODE_OPTIONS="--max-old-space-size=8192"
 ENV DL_ENV_TYPE="selfHosted"
 RUN npm run build

-# Stage 2 - run: Alpine-based runtime to serve the app
-FROM node:20.12.0-alpine AS runner
+# Stage 2 - run: slim-based runtime to serve the app
+FROM node:20.12.0-slim AS runner

 # Install PostgreSQL client to run pg_isready and psql
-RUN apk add --no-cache postgresql-client
+RUN apt-get update && apt-get install -y postgresql-client

 # Create non-root app user
-RUN addgroup -S appgroup && adduser -S appuser -G appgroup
+RUN addgroup --system appgroup && adduser --system --ingroup appgroup appuser

Logs

No response

System

No response

Before submitting

  • I have clearly described the issue and included all relevant information
  • I have checked the documentation for a solution
  • I have confirmed that this issue has not already been reported
  • I have redacted any sensitive information from logs or debug data
  • I agree to follow the Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions