I am experiencing a network connectivity issue while building a Docker image for my Node.js project, which uses Express and Prisma ORM to communicate with a PostgreSQL database. The error occurs specifically at the npx prisma generate
step. Below is my Dockerfile:
FROM node:20
WORKDIR /app
COPY . .
RUN npm install
RUN npx prisma generate
RUN npm run build
EXPOSE 3000
CMD ["node", "dist/index.js"]
During the build process, I encounter the following error:
Error: request to https://binaries.prisma.sh/all_commits/34ace0eb2704183d2c05b60b52fba5c43c13f303/debian-openssl-3.0.x/schema-engine.sha256 failed, reason: getaddrinfo EAI_AGAIN binaries.prisma.sh
DNS Settings:
8.8.8.8
and 8.8.4.4
).Network Mode:
--network host
option during the build process.Base Image:
node:18-alpine
and node:18-slim
.Proxy Check:
Network Connectivity Test in Temporary Container:
Initial success but subsequent failure in accessing the Alpine package repositories:
docker run --rm -it alpine sh -c "apk add --no-cache curl && curl -I https://binaries.prisma.sh"
Initial output indicated connectivity:
HTTP/2 404
date: Mon, 15 Jul 2024 14:57:00 GMT
content-type: text/html
vary: Accept-Encoding
cache-control: max-age=120
cf-cache-status: MISS
server: cloudflare
cf-ray: 8a3a9a3adc253b27-BOM
Subsequent attempts failed:
fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/main/x86_64/APKINDEX.tar.gz
WARNING: fetching https://dl-cdn.alpinelinux.org/alpine/v3.20/main: temporary error (try again later)
fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/community/x86_64/APKINDEX.tar.gz
WARNING: fetching https://dl-cdn.alpinelinux.org/alpine/v3.20/community: temporary error (try again later)
Manual Dependency Installation:
Busybox Container Network Test:
Ran a busybox
container to test network connectivity:
docker run --rm busybox ping -c 4 google.com
Output:
PING google.com (142.250.192.78): 56 data bytes
64 bytes from 142.250.192.78: seq=0 ttl=254 time=44.824 ms
64 bytes from 142.250.192.78: seq=1 ttl=254 time=44.824 ms
64 bytes from 142.250.192.78: seq=2 ttl=254 time=44.874 ms
64 bytes from 142.250.192.78: seq=3 ttl=254 time=45.367 ms
--- google.com ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 44.824/44.972/45.367 ms
Docker Network Configuration:
Inspected the bridge network configuration:
docker network inspect bridge
Output:
[
{
"Name": "bridge",
"Id": "1b48727c2e54967fbf86f3d1c68ca36677d24f5792ffb8508dfe4e714aca9611",
"Created": "2024-07-15T14:46:24.798485127Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0",
"com.docker.network.driver.mtu": "1500"
},
"Labels": {}
}
]
Any suggestions or solutions would be greatly appreciated. Thank you!
If you need any additional information about my environment or configuration, please let me know, and I will provide it promptly.
I have also tried all the measures in your question and finally found out that my router has DNS proxy enabled , i disabled and enabled the DNS proxy in my routers gateway and the issue was gone.
If you still can't get it working . Connect your machine to your mobile data and I am sure it will work.