Docker NPM Timeout on Linode

Hey Everybody,

I'm attempting to build a Node Docker image. After executing the docker build command, it times out on the RUN npm install step. What gets me is that this only occurs on my Linode. It build fine on my Mac, locally.

Here are the contents of my Dockerfile:

FROM node
LABEL org.label-schema.version=v1.1
ENV NODE_ENV="development"
ENV PORT 3000

RUN mkdir -p /var/node
ADD src/ /var/node/
WORKDIR /var/node
RUN npm install
EXPOSE $PORT
CMD ./bin/www

Here is the error:

Step 10/12 : RUN npm install
 ---> Running in c4eee0065d20
npm ERR! network timeout at: https://registry.npmjs.org/acorn- 
globals/-/acorn-globals-3.1.0.tgz

3 Replies

Hi there,

Since Docker didn't show you a similar network error message with the FROM instruction, it means the Linode is able to reach Docker Hub and download the node image. However, the container is not able to grab acorn-globals-3.1.0.tgz from the Internet.

I would first manually test if you are able to get the library from the Linode:

wget https://registry.npmjs.org/acorn-globals/-/acorn-globals-3.1.0.tgz

Then, I would test if the node container is able to reach the Internet and then if it's capable of downloading the library. Here's how that looked like on my Linode:

root@death-star:~# docker run -it node sh
#
# ping google.com
PING google.com (172.217.164.206) 56(84) bytes of data.
64 bytes from yyz12s04-in-f14.1e100.net (172.217.164.206): icmp_seq=1 ttl=53 time=0.743 ms
64 bytes from yyz12s04-in-f14.1e100.net (172.217.164.206): icmp_seq=2 ttl=53 time=0.845 ms
64 bytes from yyz12s04-in-f14.1e100.net (172.217.164.206): icmp_seq=3 ttl=53 time=0.829 ms
64 bytes from yyz12s04-in-f14.1e100.net (172.217.164.206): icmp_seq=4 ttl=53 time=0.851 ms
^C
--- google.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3039ms
rtt min/avg/max/mdev = 0.743/0.817/0.851/0.043 ms
#
#
# wget https://registry.npmjs.org/acorn-globals/-/acorn-globals-3.1.0.tgz
--2020-04-12 16:01:10--  https://registry.npmjs.org/acorn-globals/-/acorn-globals-3.1.0.tgz
Resolving registry.npmjs.org (registry.npmjs.org)... 104.16.17.35, 104.16.21.35, 104.16.20.35, ...
Connecting to registry.npmjs.org (registry.npmjs.org)|104.16.17.35|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3541 (3.5K) [application/octet-stream]
Saving to: 'acorn-globals-3.1.0.tgz'

acorn-globals-3.1.0.tgz                        100%[===================================================================================================>]   3.46K  --.-KB/s    in 0s

2020-04-12 16:01:10 (7.67 MB/s) - 'acorn-globals-3.1.0.tgz' saved [3541/3541]

Alternatively to wget, you can also attempt to npm install acorn-globals inside the container:

# npm install acorn-globals
npm WARN saveError ENOENT: no such file or directory, open '/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/package.json'
npm WARN !invalid#1 No description
npm WARN !invalid#1 No repository field.
npm WARN !invalid#1 No README data
npm WARN !invalid#1 No license field.

+ acorn-globals@6.0.0
added 3 packages from 1 contributor and audited 3 packages in 0.426s
found 0 vulnerabilities

If none of the commands above work inside your container, it probably means there's a network configuration issue. To determine if this might be related to DNS, try to ping Google's DNS servers directly inside the node container:

root@death-star:~# docker run -it node sh
# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=53 time=0.481 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=53 time=0.534 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=53 time=0.540 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=53 time=0.602 ms
^C
--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3052ms
rtt min/avg/max/mdev = 0.481/0.539/0.602/0.045 ms

Give it a shot and let us know your results.

i am having a similar issue

$ docker run busybox nslookup google.com
;; connection timed out; no servers could be reached

$ docker run busybox nslookup google.com 8.8.8.8
;; connection timed out; no servers could be reached

$ docker run busybox nslookup google.com 50.116.53.5
;; connection timed out; no servers could be reached

$ docker run busybox ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes

--- 8.8.8.8 ping statistics ---
242 packets transmitted, 0 packets received, 100% packet loss

in our case, using the docker build --network=host option seemed to be the only solution

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct