Sign inSign up

sanrep/gitserver

By sanrep

•Updated about 3 years ago

Git server in docker

Image
0

5.2K

sanrep/gitserver repository overview

⁠Git Server

Test Build Status Docker Image Size Docker Pulls

Docker image containing a Git server accessible via SSH.

Image source at: https://github.com/sanrep/docker-gitserver⁠.

Git server configuration allows use cases which are detailed in the source README⁠:

  • Setup custom password for git user
  • Use SSH public keys
  • Turn off password authentication
  • Setup custom host SSH keys
  • Enable use of shorter git URLs
  • Set git user UID and GID
  • Disable interactive SSH login of git user

⁠Usage

⁠Run git server
⁠Quick setup

For quick setup (not recommended for production) create directory for git repositories and run:

docker run -d \
    -v /git/repositories/dir:/srv/git \
    -p 2222:22 \
    sanrep/gitserver

Default password for git user is 12345.

⁠Advanced setup

Advanced setup on host:

  • Define GIT_PASSWORD environment variable with the password for git user in .env file (if not set, for testing, default is 12345)
  • Create directory for git repositories
  • Create directory for host SSH keys and generate them (see source README⁠)
  • Create authorized_keys file, and set it's permissions to 600
  • Add clients' public keys to authorized_keys (see source README⁠)

Then run git server container:

docker run -d \
    -v /git/repositories/dir:/srv/git \
    -v /authorized/keys/dir/authorized_keys:/home/git/.ssh/authorized_keys \
    -v /ssh/host/keys/dir:/ssh_host_keys:ro \
    --env-file .env
    -p 2222:22 \
    sanrep/gitserver

Or create .env file and use docker-compose.yml from source⁠:

cp .env.sample .env
vim .env
docker compose up -d
⁠Create New Git Repository

Log into git server through SSH:

ssh [email protected] -p 2222

Replace gitserverhost.com with DNS name (or IP address) of the host where git server is deployed.

Create and initialize bare git repository (.git suffix is not needed):

new your-repo

To clone repository from git server:

git clone ssh://[email protected]:2222/srv/git/your-repo.git
⁠Use shorter URLs

You can set shorter URLs as described in source⁠. Then you can login into server:

ssh my_git_server

To clone repository:

git clone my_git_server:git/your-repo.git

⁠Supported Tags and Variants

See Variants⁠ and Tagging Scheme⁠.

⁠License

View license information⁠ for the software contained in this image.

As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).

As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.

⁠Credits

This docker image is based on excellent rockstorm's⁠ git-server-docker.

Customizations include:

  • usage of docker compose for running container
  • recommended setup is default
  • separation of environment variables into .env file
  • usage of environment variable to disable interactive SSH login
  • custom git-shell commands (list and new)
  • creating new git repositories with main as initial branch
  • same git and docker image tags which comply with semantic versioning⁠

Tag summary

Content type

Image

Digest

sha256:9866c18ed…

Size

10.2 MB

Last updated

about 3 years ago

docker pull sanrep/gitserver