docker - Npm install 特定版本在 Dockerfile 中不起作用
问题描述
我正在尝试在图像(最新标签)中安装特定版本的 npm 包node:alpine
,所以这是我在 Dockerfile 中指定的:
编辑(这是完整的 Dockerfile):
FROM node:alpine as build-stage
ARG SONAR_VERSION=4.6.0.2311
RUN apk add --no-cache zip unzip
RUN wget -c https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_VERSION-linux.zip
RUN unzip -q sonar-scanner-cli-$SONAR_VERSION-linux.zip
RUN rm sonar-scanner-cli-$SONAR_VERSION-linux.zip
# Adding the $install_directory/bin directory to path
RUN cd sonar-scanner-$SONAR_VERSION-linux
RUN echo $PWD
RUN export PATH="$PATH:/$PWD/bin"
RUN npm i -g eslint@6.7.2
RUN npm i -g eslint-plugin-vue --save-dev
但是,当我运行并执行构建的映像时,安装的 eslint 版本是最新版本,而不是我在 Dockerfile 中指定的版本。
结果来自npm list -g
:
/ # npm list -g
/usr/local/lib
+-- eslint-plugin-vue@7.9.0
+-- eslint@7.25.0
`-- npm@7.11.2
如果我npm i -g eslint@6.7.2
在容器本身中运行,则版本npm list -g
将完全是我指定的版本。
这种情况的原因是什么?
解决方案
推荐阅读
- javascript - 无法在 GatsbyJS 函数中添加代码注释
- python - 如何在不敏感的情况下逐行比较熊猫中的两个数据帧?
- python - 优化 Python 代码以进行逐行比较
- powerbi - PowerBi Measure - 除以基于另一个值的值
- r - 当在`中定义变量时如何在R中编写for循环
- c# - 如何使用 MigraDoc 和 C# 将超链接添加到标题图像?
- string - Logstash 输入日志文件的 Grok 模式
- linux - 在 bash 中创建空文件的简写在 zsh 中无法正常工作
- javascript - JavaScript display = "none" 不停止函数
- firebase - firebase-admin-sdk-go FCM 消息传递线程安全