Docker中的NPM安装失败-“无法建立连接,因为目标机器主动拒绝它”

htrmnn0y  于 2023-10-16  发布在  Docker
关注(0)|答案(1)|浏览(248)

我正在尝试从本地Github仓库运行演示VS Code扩展。它在一个容器里。我现在使用的是Windows,使用的是Docker Desktop。当我尝试运行Docker时,它给了我这个错误:

139.5 E: Failed to fetch http://deb.debian.org/debian/pool/main/n/node-string-width/node-string-width_4.2.3%2b%7ecs13.2.3-1_all.deb  403  connecting to deb.debian.org:80: connecting to :80: dial tcp :80: connectex: No connection could be made because the target machine actively refused it. [IP: 80]
139.5 E: Failed to fetch http://deb.debian.org/debian/pool/main/n/node-wrap-ansi/node-wrap-ansi_8.0.1%2b%7e8.0.1-3_all.deb  403  connecting to deb.debian.org:80: connecting to :80: dial tcp :80: connectex: No connection could be made because the target machine actively refused it. [IP:  80]
139.5 E: Failed to fetch http://deb.debian.org/debian/pool/main/n/node-cliui/node-cliui_7.0.4%2brepack%2b%7ecs3.1.0-4_all.deb  403  connecting to deb.debian.org:80: connecting to :80: dial tcp :80: connectex: No connection could be made because the target machine actively refused it. [IP: 80]
------
failed to solve: process "/bin/sh -c apt install -y npm" did not complete successfully: exit code: 100

到目前为止,我只尝试在Docker Desktop上打开Expose daemon on tcp://localhost:2375 without TLS.选项,并重新启动我的机器和路由器,但它仍然产生相同的错误。
如何修复此错误?在此先谢谢您!
编辑:我尝试将“8.8.8.8“作为DNS添加到我的Docker守护进程中,如下所示,它给了我多个错误,如下所示:

210.7 E: Failed to fetch http://deb.debian.org/debian/pool/main/n/node-promise-retry/node-promise-retry_2.0.1-4_all.deb  403  connecting to deb.debian.org:80: resolving host deb.debian.org: lookup deb.debian.org: getaddrinfow: This is usually a temporary error during hostname resolution and means that the local server did 
not receive a response from an authoritative server. [IP: 80]

Dockerfile是这样的:

# Step 1: Use official lightweight Python image as base OS.
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.7

# ARG GOOGLE_APPLICATION_CREDENTIALS="/usr/src/app/serviceAccount.json"

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Install app dependencies

# Bundle app source
COPY app /usr/src/app
ENV GOOGLE_APPLICATION_CREDENTIALS="./serviceAccount.json"
ENV SENTRY_SDK_DSN="https://[email protected]/5783806"

WORKDIR pdf2jsonl
ENV PATH pdf2jsonl/node_modules/.bin:$PATH
COPY package.json .
COPY package-lock.json .
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
RUN apt update && apt-get upgrade -y
RUN apt-get install -y nodejs
RUN npm install
COPY . ./
RUN sed -i 's/token in cache/token in cache \&\& typeof cache[token] === "string"/g' node_modules/gpt-3-encoder/Encoder.js

WORKDIR ..
# Step 3. Install production dependencies.
RUN pip install -r requirements.txt

EXPOSE 80

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]

docker-compose.yml文件看起来像这样:

version: '3.8'

services:
  web:
    build: ./app
    command: uvicorn main:app --reload --workers 1 --host 0.0.0.0 --port 8000
    volumes:
      - ./app:/usr/src/app
      - /usr/src/app/pdf2jsonl/node_modules
    ports:
      - 8000:8000
    environment:
      - ENVIRONMENT=dev
      - TESTING=0
      - GOOGLE_APPLICATION_CREDENTIALS=/usr/src/app/serviceAccount.json
dxxyhpgq

dxxyhpgq1#

您的apt update步骤可能已缓存(导致安装步骤请求不正确的端点)。尝试在不使用该高速缓存的情况下运行构建或清理系统:docker system prune --all并再次尝试构建。

相关问题