在 Docker 镜像创建过程中安装 Nodejs

问题描述 投票:0回答:1

我在尝试创建第一个 docker 映像时遇到问题。

这是我的 docker 文件:

FROM debian:9

RUN apt-get update -yq \
    && apt-get install -yq curl gnupg \
    && curl -sL https://deb.nodesource.com/setup_10.x | bash \
    && apt-get install -yq nodejs \
    && apt-get clean

ADD . /app/
WORKDIR /app
RUN npm install

EXPOSE 2368
VOLUME /app/logs

CMD npm run start

我的文件夹中确实有一个包含所有依赖项的 package.json 文件,但我仍然有此错误作为响应:

ERROR: failed to solve: process "/bin/sh -c apt-get update      && apt-get install curl gnupg     && curl -sL https://deb.nodesource.com/setup_10.x | bash     && apt-get install -y nodejs     && apt-get clean" did not complete successfully: exit code: 100
node.js docker docker-image
1个回答
0
投票

您可以使用 Docker Hub

提供的节点官方 docker 镜像

更多关于 NodeJS Dockerizing

FROM node:18 #node version

# Create app directory
WORKDIR /app

# Layer caching
COPY package*.json ./

# Install app dependencies
RUN npm install

COPY . .

EXPOSE 8080

VOLUME /app/logs

CMD npm run start
© www.soinside.com 2019 - 2024. All rights reserved.