Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we update git version in the Docker Image?

I'm using docker to install my dependencies. Using Node:10.13.0 as

FROM: node:10.13.0

All dependencies installed well except Husky.

And it shows the following:

Husky requires Git >=2.13.0. Got v2.11.0.   
husky > Failed to install

So, the problem is that the git version is below 2.13.

Searched for init git version in the docker file. But I don't get any solution.

Is any other way to set the git version in the docker file?.

like image 359
Surya S Avatar asked Apr 20 '26 19:04

Surya S


1 Answers

  • Next means node:10.13.0 use debian9, aka stretch.

    $ docker run --rm node:10.13.0 cat /etc/issue
    Debian GNU/Linux 9 \n \l
    
  • Next means node:10.13.0 default use git 2.11.

    $ docker run --rm node:10.13.0 git --version
    git version 2.11.0
    

In fact, git in debian 9 apt repo use the version 2.11, if you want to upgrade to a newer version, you could use debian backports, which means:

Backports are packages taken from the next Debian release

By default, backports won't be used when use apt. You could use next sample to enable this.

Dockerfile:

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

Verify it:

$ 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
like image 200
atline Avatar answered Apr 23 '26 08:04

atline



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!