Sign inSign up

yoas1/mini-git-server

By yoas1

Updated about 1 month ago

Image
0

365

yoas1/mini-git-server repository overview

Mini Git Server

A lightweight, secure, and minimal SSH-based Git server running inside a Docker container.


Quick Start Guide

1. Prepare Public Key Authentication

Prepare an authorized_keys file containing your SSH public key to grant access to the container:

cat ~/.ssh/id_rsa.pub > authorized_keys

2. Run the Container

Start the container by mapping the repository directory and mounting your authorized_keys file:

docker run -d \
  --name mini-git-server \
  -p 2222:22 \
  -v /path/to/repos-data:/data \
  -v /path/to/authorized_keys:/home/git/.ssh/authorized_keys \
  yoas1/mini-git-server:latest
Configuration Details
  • -p 2222:22: Maps host port 2222 to the container's SSH port 22.
  • -v /path/to/repos-data:/data: Persistent storage directory for bare Git repositories.
  • -v /path/to/authorized_keys:/home/git/.ssh/authorized_keys: Mounts public SSH keys for passwordless authentication.

3. Verify SSH Connection

Test your SSH connection to verify key authentication:

ssh -p 2222 git@<SERVER_IP>

4. Create a Bare Repository

Access the container and initialize a new bare repository with main as the default branch:

# Access container shell
docker exec -it mini-git-server bash

# Initialize repository
cd /data
git init --bare -b main <repo-name>.git

5. Clone and Push from Workstation

On your local machine, clone the repository, create an initial commit, and push your changes:

# Clone the repository using full SSH syntax
git clone ssh://git@<SERVER_IP>:2222/data/<repo-name>.git
cd <repo-name>

# Create initial commit
echo "# Project Title" > README.md
git add README.md
git commit -m "Initial commit"

# Set default branch and push to remote
git branch -M main
git push -u origin main

Tag summary

Content type

Image

Digest

sha256:493e51d3a

Size

135 MB

Last updated

about 1 month ago

docker pull yoas1/mini-git-server