This is a minimal Git image based. The image contains git, git-lfs, and supporting libraries such as openssh (for ssh-based auth), and ca-certs (for https-based cloning). Both Wolfi (glibc) and Alpine (musl) versions are available.
The image is available on cgr.dev:
docker pull cgr.dev/chainguard/git:latest
Or for the glibc version:
docker pull cgr.dev/chainguard/git:latest-glibc
The Git image allows you to run ordinary Git commands in CI/CD pipelines and also locally via Docker.
To make sure you have the latest image version available, start by running a docker pull command:
docker pull cgr.dev/chainguard/git
Then, run the image with the --version flag to make sure it is functional:
docker run -it --rm cgr.dev/chainguard/git --version
You should get output similar to this:
git version 2.37.1
Because your local system user’s ID (uid) might differ from that of the container image, if you want to clone repositories locally using this image you’ll need to set up special permissions for the target dir. Then, you’ll be able to set up a volume and have the contents of the cloned repo replicated on your host machine.
First, create a target directory somewhere in your home folder and set the required permissions:
chmod go+wrx ~/workspace
Now you can use docker run to execute the clone command, using the directory you just set up as a volume share between your local machine and the container image on /home/git.
docker run -it -v ~/workspace:/home/git --rm cgr.dev/chainguard/git clone https://github.com/chainguard-images/.github.git
You should get output like this:
Cloning into '.github'...
remote: Enumerating objects: 217, done.
remote: Counting objects: 100% (104/104), done.
remote: Compressing objects: 100% (74/74), done.
remote: Total 217 (delta 39), reused 78 (delta 27), pack-reused 113
Receiving objects: 100% (217/217), 207.47 KiB | 1.46 MiB/s, done.
Resolving deltas: 100% (70/70), done.
You can now check the contents of your workspace directory, where you should find the cloned repo.