Docker node service return ECONNRESET network error when running npm install in docker container

Viewed 792

I have set up a simple laravel application using docker-compose.

Everything works fine, aside from node service.

When I run docker-compose run --rm node npm install in the project folder I receive the following error after the command works for some time enter image description here

Also here is my docker-compose.yml file

version: "3.7"

services: app: build: args: user: delll uid: 1000 context: ./ dockerfile: Dockerfile image: landing-app restart: unless-stopped working_dir: /var/www/ volumes: - ./:/var/www networks: - landing

nginx:
    image: nginx:alpine
    restart: unless-stopped
    ports:
    - 8000:80
    volumes:
    - ./:/var/www
    - ./docker-compose/nginx:/etc/nginx/conf.d/
    networks:
    - landing

node:
    image: node:15.5-alpine3.10
    working_dir: /assets
    volumes: 
        - ./:/assets
    command: "npm run watch" 

db:
    image: mysql:8
    restart: unless-stopped
    environment:
        MYSQL_DATABASE: ${DB_DATABASE}
        MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
        MYSQL_PASSWORD: ${DB_PASSWORD}
        MYSQL_USER: ${DB_USERNAME}
    networks:
        - landing

networks: landing: driver: bridge

1 Answers

FYI After facing the same issue and looking at DOZENS of posts including this one (whose solution seems mighty complicated) what worked was a simple proxy config to be passed to npm itself. This fixed it during the docker build process. All I had to do was add these lines to my Dockerfile BEFORE running the npm install command :-

RUN npm config set http-proxy http://<my company proxy>:8099

RUN npm config set https-proxy http://<my company proxy>:8099

Related