链接Dockerfiles - 从开始运行NPM不再工作?

发布于 2025-02-05 19:15:44 字数 843 浏览 0 评论 0原文

我正在尝试Docker。我有一个简单的Dockerfile,其中包括Java和Node。

https://github.com/quafadas/quafadas/scala-mill

“ rel =” nofollow noreferrer“> https://github.com/quafadas/quafadas/quafadas/scala-mill/blob/blob/blob/master/master/dockerfile/dockerfile

//github.com/quafadas/scala-mill/blob/master/dockerfile dockerhub。现在,我想在下游构建一个应用程序

FROM quafadas/scala-mill:latest
RUN java -version
#This doesn't work :-(.
RUN npm --version

运行npm - version在上面链接的基本图像中工作,但显然不是当我使用来自指令。有人能帮助我理解为什么吗?

/bin/sh: npm: command not found
15:15:19
      The command '/bin/sh -c npm --version' returned a non-zero code: 127
    enter code here
``

I'm experimenting with docker. I have a simple dockerfile, which includes java and node.

https://github.com/Quafadas/scala-mill

https://github.com/Quafadas/scala-mill/blob/master/Dockerfile

It's published to dockerhub. Now, I'd like to build an application downstream

FROM quafadas/scala-mill:latest
RUN java -version
#This doesn't work :-(.
RUN npm --version

The command RUN npm --version works in the base image linked above, but apparently, not when I'm building on top of it using the FROM directive. Is anyone able to help me understand why?

/bin/sh: npm: command not found
15:15:19
      The command '/bin/sh -c npm --version' returned a non-zero code: 127
    enter code here
``

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

与之呼应 2025-02-12 19:15:44

似乎最近有几项承诺 repo 显然已经解决了问题!我能够构建并运行Dockerfile,以获取npm版本,没有任何问题!

如果您需要在不提供它的基本图像上安装其他模块(例如NPM),请使用命令的多阶段dockerfile,具有不同的稍后,您将必要的依赖项和Docker映像中的单个dockerfile获取。 参考

There seem to have been a few recent commits to the repo which has apparently fixed the issue! I was able to build and run the Dockerfile to get the npm version without any issues!

enter image description here

In case you need additional modules (such as npm) to be installed on a base image that doesn't provide it, use a multi-stage Dockerfile with different FROM commands to get your necessary dependencies onto a single Dockerfile and a docker image later. Reference.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文