Skip to content

gitlab-ce-docker Plugin

This plugin installs GitLab CE(Community Edition) on Docker.

NOTICE: currently, this plugin support Linux only.

Background

GitLab officially provides an image gitlab-ce. We can use this image to start a container:

Bash
docker run --detach \
  --hostname gitlab.example.com \
  --publish 443:443 --publish 80:80 --publish 22:22 \
  --name gitlab \
  --restart always \
  --volume $GITLAB_HOME/config:/etc/gitlab \
  --volume $GITLAB_HOME/logs:/var/log/gitlab \
  --volume $GITLAB_HOME/data:/var/opt/gitlab \
  --shm-size 256m \
  gitlab/gitlab-ce:rc

The variable $GITLAB_HOME here pointing to the directory where the configuration, logs, and data files will reside.

We can set this variable by the export command:

Bash
export GITLAB_HOME=/srv/gitlab

The GitLab container uses host mounted volumes to store persistent data:

Local location Container location Usage
$GITLAB_HOME/data /var/opt/gitlab For storing application data
$GITLAB_HOME/logs /var/log/gitlab For storing logs
$GITLAB_HOME/config /etc/gitlab For storing the GitLab configuration files

So, we can customize the following configurations:

  1. hostname
  2. host port
  3. persistent data path
  4. docker image tag

Configuration

Note: 1. the user you are using must be root or in the docker group; 2. https isn't supported for now.

YAML
tools:
# name of the tool
- name: gitlab-ce-docker
  # id of the tool instance
  instanceID: default
  # format: name.instanceID; If specified, dtm will make sure the dependency is applied first before handling this tool.
  dependsOn: [ ]
  # options for the plugin
  options:
    # hostname for running docker. (default: gitlab.example.com)
    hostname: gitlab.example.com
    # pointing to the directory where the configuration, logs, and data files will reside.
    # (default: /srv/gitlab)
    # 1. it should be a absolute path
    # 2. once the tool is installed, it can't be changed
    gitlabHome: /srv/gitlab
    # ssh port exposed in the host machine. (default: 22)
    sshPort: 22
    # http port exposed in the host machine. (default: 80)
    httpPort: 80
    # https port exposed in the host machine.
    # (default: 443)
    # todo: support https, reference: https://docs.gitlab.com/omnibus/settings/nginx.html#enable-https
    httpsPort: 443
    # whether to delete the gitlabHome directory when the tool is removed. (default: false)
    rmDataAfterDelete: false
    # gitlab-ce tag. (default: "rc")
    imageTag: "rc"

Some Commands That May Help

  • clone code
Bash
export hostname=YOUR_HOSTNAME
export username=YOUR_USERNAME
export project=YOUR_PROJECT_NAME
  1. ssh
Bash
# port is 22
git clone git@${hostname}/${username}/${project}.git
# port is not 22, 2022 as a sample
git clone ssh://git@${hostname}:2022/${username}/${project}.git
  1. http
Bash
# port is 80
git clone http://${hostname}/${username}/${project}.git
# port is not 80, 8080 as a sample
git clone http://${hostname}:8080/${username}/${project}.git