Skip to content

npm not working behind a proxy in docker (16.7+) #3561

@bujinin

Description

@bujinin

Version

16.7+

Platform

Docker 20.10.7 on Linux 4.15.0-158-generic nodejs/node#166-Ubuntu x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

I'm trying to build a node-app in docker with the following Dockerfile

FROM node:16.7 as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
...

Building the app (docker build -t app:test .) results in an error.

How often does it reproduce? Is there a required condition?

For every node-image v16.7+. In 16.6 and lower, everything works fine

What is the expected behavior?

Install the dependencies

What do you see instead?

npm WARN deprecated @types/[email protected]: This is a stub types definition for localforage (https://github.com/localForage/localForage). localforage provides its own type definitions, so you don't need @types/localforage installed!
npm WARN deprecated @hapi/[email protected]: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/[email protected]: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: This loader has been deprecated. Please use eslint-webpack-plugin
npm WARN deprecated @hapi/[email protected]: Moved to 'npm install @sideway/address'
npm WARN deprecated [email protected]: Deprecated due to CVE-2021-21366 resolved in 0.5.0
npm WARN deprecated [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: 3.x is no longer supported
npm WARN deprecated @hapi/[email protected]: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated @hapi/[email protected]: Switch to 'npm install joi'
npm notice 
npm notice New minor version of npm available! 7.20.3 -> 7.24.1
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.24.1>
npm notice Run `npm install -g [email protected]` to update!
npm notice 
npm ERR! code ECONNRESET
npm ERR! syscall read
npm ERR! errno -104
npm ERR! network read ECONNRESET
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network 
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-09-29T14_01_17_394Z-debug.log

Additional information

Proxy is properly set for the docker client and for the daemon and work correctly (tested in multiple other containers/apps).
When trying to run a container manually (docker run -it --rm node:16.7 /bin/bash) and reproduce the steps , everything works fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions