Hi,
I’m following the basic Docker tutorials and now executing the following to create and image:
# Start your image with a node base image
FROM node:18-alpine
# The /app directory should act as the main application directory
WORKDIR /app
# Copy the app package and package-lock.json file
COPY package*.json ./
# Copy local directories to the current local directory of our docker image (/app)
COPY ./src ./src
COPY ./public ./public
# Install node packages, install serve, build the app, and remove dependencies at the end
RUN npm install \
&& npm install -g serve \
&& npm run build \
&& rm -fr node_modules
EXPOSE 3000
# Start the app using serve command
CMD [ "serve", "-s", "build" ]
The result is that it’s stuck at “npm install” and not seeming to progress (unless this is supposed to take a couple hours which I’ve not tried yet).
~/welcome-to-docker$ docker build -t welcome-to-docker-test .
[+] Building 1371.8s (9/10) docker:desktop-linux
=> [internal] load build context 0.0s
=> => transferring context: 393B 0.0s
=> CACHED [2/6] WORKDIR /app 0.0s
=> CACHED [3/6] COPY package*.json ./ 0.0s
=> CACHED [4/6] COPY ./src ./src 0.0s
=> CACHED [5/6] COPY ./public ./public 0.0s
=> [6/6] RUN npm install && npm install -g serve && npm run build && rm -fr node_modules 3370.8s
=> => # npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the
=> => # compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compa
=> => # tibility
=> => # npm WARN deprecated rollup-plugin-terser@7.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plug
=> => # in-terser
=> => # npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
Neither CPU, Memory or network seem to be the bottleneck:
I have the same issue with Docker version 24.0.2 (after the upgrade, but I also tried with an older version, I don’t remember which) and the package node:18. I also tried with node:16.20 and node:17.8.
I didn’t have this issue until recently. I think it was possibly introduced in a recent Docker update? Same version of node, same package.json, same base image, but now ‘npm install’ is taking ridiculously long to install dependencies.
However, fortunately: RUN npm config set strict-ssl false
Also fixed it for me.
I face the same issue and it’s like Tom said: It worked previously and nothing changed. I just noticed because I wanted to build an image with the no-cache flag and it took forever: npm install ~ 30 minutes, the following npm install @angular/cli over an hour! After that, using the cache again it was all good.
I retried this with the suggested fix. This brought npm install down to a minute, but the angular cli was still endless. I killed the process after two hours.
I really hope somebody can figure out, what this issue is. My knowledge is enough to use things, but not to troubleshoot it and this is really slowing things down quite literally.
I have the same issue. Started to observe this issue when switched to the new Internet provider. If I switch to my mobile internet “npm install” works. So it looks like some network firewall or something blocks the request.
“strict-ssl false” also didn’t help
Stumbled across this thread while searching for the same issue, so it might be connected. I have currently the same issue in building Migrate code to Typescript and eslint flat config by jopicornell · Pull Request #91 · janjaali/sendGrid-mock · GitHub with latest Docker version 27.3.1, build ce12230 on Windows, while the same build is running green on GitHub Actions using Ubuntu. The mentioned RUN npm config set strict-ssl false although helped already in resolving the issue in short run for me.