Skip to content

Instantly share code, notes, and snippets.

@nicc777
Last active April 26, 2022 08:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicc777/26641b141e0a00d900e99969d7730ff7 to your computer and use it in GitHub Desktop.
Save nicc777/26641b141e0a00d900e99969d7730ff7 to your computer and use it in GitHub Desktop.
Gitlab Community Edition (Docker) with persistant volumes

Prepare volumes

Also refer to the GitLab Documentation

docker volume create gitlab-data
docker volume create gitlab-logs
docker volume create gitlab-config

Start GitLab (First Run)

Refer to Docker Hub for the available versions

Prepare the following environment variables:

Environment Variable Content Example
GITLAB_HOSTNAME Hostname export GITLAB_HOSTNAME="192.168.2.6"
GITLAB_SECURE_PORT HTTPS Port export GITLAB_SECURE_PORT=7443
GITLAB_INSECURE_PORT HTTP Port export GITLAB_INSECURE_PORT=7080
GITLAB_SSH_PORT SSH Port export GITLAB_SSH_PORT=7022
GITLAB_VERSION The version export GITLAB_VERSION="14.10.0-ce.0"
GITLAB_RESTART_POLICY The restart policy export GITLAB_RESTART_POLICY="unless-stopped"

And then start GitLab with the following command:

docker run --detach \
  --hostname $GITLAB_HOSTNAME \
  --publish $GITLAB_SECURE_PORT:443 --publish $GITLAB_INSECURE_PORT:80 --publish $GITLAB_SSH_PORT:22 \
  --name gitlab \
  --restart $GITLAB_RESTART_POLICY \
  --mount source=gitlab-config,target=/etc/gitlab \
  --mount source=gitlab-logs,target=/var/log/gitlab \
  --mount source=gitlab-data,target=/var/opt/gitlab \
  --shm-size 256m \
  gitlab/gitlab-ce:$GITLAB_VERSION

Note: The first run can take a minute or two for setup to complete.

Initial root password

Run the following:

docker exec -it gitlab cat /etc/gitlab/initial_root_password

Post installation tasks

Typically the following tasks should be performed post installation:

  1. Set the root password
  2. Disable user self-registration (unless you want users to self-register)
  3. Create a normal user for you
  4. Load your SSH public key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment