【问题标题】:Docker(compose) installing nodejs broke npmDocker(compose) 安装 nodejs 破坏了 npm
【发布时间】:2017-11-12 16:51:27
【问题描述】:

我需要使用一个带有nginx和nodejs的容器,所以我拿了nginx容器并安装了节点:

FROM nginx

ENV DEBIAN_FRONTEND noninteractive

WORKDIR /usr/src/app
VOLUME /usr/src/app


RUN apt-get update && \
  apt-get install -y apt-utils && \
  apt-get install -y --no-install-recommends curl sudo wget nano && \
  curl -sL https://deb.nodesource.com/setup_6.x | bash - && \
  apt-get install -y nodejs git build-essential && \
  whereis npm && \
  npm install grunt grunt-cli bower -g && \

whereis 没有返回任何东西 npm:npm install... 使构建过程崩溃。所以我的错误在哪里,有错误还是什么?顺便说一句,我正在使用最新的 docker-compose 和 Docker 版本 17.03.1-ce,构建 c6d412e

更新1:不是this question的骗子,我只用了一条RUN线

【问题讨论】:

  • @NazariiBardiuk 这不是一个重复,因为我只使用一个 RUN,这个 dockerfile 上个月也可以工作

标签: node.js nginx docker npm docker-compose


【解决方案1】:
FROM nginx

RUN \
    echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections && \
    apt-get update && \
    apt-get install -y apt-utils && \
    apt-get upgrade -y && \
    apt-get update --fix-missing && \
    apt-get install -y curl sudo wget nano git build-essential

# Install NodeJS
RUN \
    wget https://deb.nodesource.com/setup_6.x && \
    chmod +x setup_6.x && \
    ./setup_6.x && \
    apt-get install -y nodejs && \
    npm install grunt grunt-cli

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-23
    • 2021-06-21
    • 1970-01-01
    • 2017-04-25
    • 1970-01-01
    • 2016-08-09
    • 2014-07-31
    • 1970-01-01
    相关资源
    最近更新 更多