#Gitolite on docker
How to run
There are two methods to run this image.
docker rundirectly. Example:
$ docker run -d -p 2222:22 --name gitolite -e SSH_KEY="$(cat ~/.ssh/id_rsa.pub)" -v /path/to/git/data:/home/git/repositories betacz/gitolite
gitolitescript from the GitHub Project.
This script contains the following variables. You can change them by modifying this file or by use the environment variable to override.
IMAGE_NAME default: "betacz/gitolite" CONTAINER_NAME default: "gitolite-server" PORT default: "2222" GIT_DATA_PATH default: "/opt/git" SSH_KEY_FILE default: "$HOME/.ssh/id_rsa.pub"
# run the container $ GIT_DATA_PATH=/var/data/git ./gitolite start # stop && remove the container $ ./gitolite stop && ./gitolite remove
The user running the script must be a member of the group
docker. Otherwise, you need to modify this script and prepend
sudoto the appropriate command.
If you don't use your own ssh key, you can get the built-in private key by
docker logs gitolitefor admin user.
You should create a directory for persistent Git repositories. This directory must have read/write permissions for current user.
The Git repositories directory you specify can also be a already exists gitolite repositories.
You can customize the gitolite
.rc file by modify the
/path/to/git/data/gitolite.rc. This file will sync to
~/.gitolite.rc when restart the container. So after change it you must run command like this:
$ ./gitolite stop && ./gitolite start
If the container accidentally removed by
docker rm or
./gitolite remove . You can start it with the command as same as before. But you must force push the
$ GIT_DATA_PATH=/var/data/git ./gitolite start $ cd ~/gitolite-admin && git push -f
Build your own image
Clone the source code and run:
$ docker build -t gitolite .
This image reinstalls the admin key (if SSH_KEY is defined) every time the container is started. gitolite ignores duplicate keys, which means if you install the same key as your username after installing it as admin, you won't have access to any repos as your username. Removing the admin key works until the container is started again (reboots, etc.)
I forked the project and modified start.sh to use a file to indicate whether gitolite had been configured the first time. This avoids gitolite from reinstalling the admin key on container start.
https://registry.hub.docker.com/u/jesselang/gitolite/ - automated build
https://github.com/hlj/docker-gitolite/pull/1 - pull request
This image runs gitolite as the "git" user, which has an ID of 1000. When creating the volume directory to store your repositories, you should "chown 1000 /path/to/git/data", and be mindful to restrict ownership and permissions of parent directories to keep UID 1000 on the host from accessing your repositories.