2021-12-10

Tech Programing

程式人小天地

npm ERR! code ERR_SOCKET_TIMEOUT When I Want Install node_modules with docker-compose

1 min read


I’m using Dockerfile to run and install node_modules for a gatsby project. The Dockerfile has the below structure:

FROM node:alpine

EXPOSE 8000

RUN apk add --update --no-cache build-base python3-dev python3 libffi-dev libressl- 
 dev bash git gettext curl 
 && curl -O https://bootstrap.pypa.io/get-pip.py 
 && python3 get-pip.py 
 && pip install --upgrade six awscli awsebcli

WORKDIR /app
COPY ./package.json .
RUN npm install

COPY . .

RUN yarn install && yarn cache clean

CMD ["yarn", "develop", "-H", "0.0.0.0" ]

And Here is the code of docker-compose.yml :

version: '3'
services:
  web:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "8000:8000"
    volumes:
      - app/node_modules
      - .:/app

After running docker-compose build command I’m getting the below error:

How can I solve this problem and install node_modules with docker?



Source link

資料來源:Stackoverflow

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *