Image Overview: git

Overview: git Chainguard Image

A minimal Git image.

Download this Image

The image is available on cgr.dev:

docker pull cgr.dev/chainguard/git:latest

Note that there is also glibc version of this Image available:

docker pull cgr.dev/chainguard/git:latest-glibc

Usage

Chainguard’s Git Image allows you to run ordinary Git commands in CI/CD pipelines and also locally via Docker.

Docker Setup

To make sure you have the latest version of the Image 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 the Image is functional:

docker run -it --rm cgr.dev/chainguard/git --version

You will receive output similar to this:

git version 2.43.0

Cloning a Repository Locally

Because your local system user’s unique identifier might differ from that of the container, you’ll need to set up special permissions for the target directory if you want to use this Image to clone repositories locally. Once you’ve configured these permissions, you’ll be able to set up a volume and have the contents of the cloned repository replicated on your host machine.

First, create a target directory somewhere in your home folder and set the required permissions:

mkdir ~/workspace
chmod go+wrx ~/workspace

Now you can use docker run to execute the git clone command, using the directory you just set up as a volume shared between your local machine and the container Image:

docker run -it -v ~/workspace:/home/git --rm cgr.dev/chainguard/git clone https://github.com/chainguard-images/.github.git

Here, the volume is mounted to the /home/git directory in the container.

This will return output like the following:

Cloning into '.github'...
remote: Enumerating objects: 251, done.
remote: Counting objects: 100% (33/33), done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 251 (delta 15), reused 22 (delta 10), pack-reused 218
Receiving objects: 100% (251/251), 216.59 KiB | 1.04 MiB/s, done.
Resolving deltas: 100% (88/88), done.

You can now check the contents of your workspace directory, where you will find the cloned repository:

ls -a ~/workspace/
.  ..  .github

Last updated: 2024-04-11 12:38