我正在使用 docker 安装我的依赖项。使用 Node:10.13.0 作为
来自:node:10.13.0
除 Husky
外,所有依赖项都安装良好。
它显示以下内容:
Husky requires Git >=2.13.0. Got v2.11.0.
husky > Failed to install
所以,问题是 git version
低于 2.13。
在 docker 文件中搜索 init git version。但我没有得到任何解决方案。
还有其他方法可以在 docker 文件中设置 git 版本吗?
最佳答案
下一步意味着
node:10.13.0
使用 debian9,又名stretch
。$ docker run --rm node:10.13.0 cat /etc/issue Debian GNU/Linux 9 \n \l
接下来表示
node:10.13.0
默认使用git 2.11
。$ docker run --rm node:10.13.0 git --version git version 2.11.0
事实上,debian 9
apt repo 中的 git
使用的是 2.11 版本,如果你想升级到更新的版本,你可以使用 debian backports
,这意味着:
Backports are packages taken from the next Debian release
默认情况下,使用apt
时不会使用backports
。您可以使用下一个示例来启用它。
Docker 文件:
FROM node:10.13.0
RUN echo "deb http://deb.debian.org/debian stretch-backports main contrib non-free" >> /etc/apt/sources.list; \
apt-get update; \
apt-get -t stretch-backports install git -y
验证它:
$ docker build -t mynodeimage .
Sending build context to Docker daemon 2.048kB
Step 1/2 : FROM node:10.13.0
......
Successfully tagged mynodeimage:latest
$ docker run --rm mynodeimage git --version
git version 2.20.1
关于git - 我们可以更新 Docker Image 中的 git 版本吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65411969/