Skip to content

Instantly share code, notes, and snippets.

@TeddyBear06
Last active January 30, 2022 16:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TeddyBear06/cedae273d0c968ae6b14cb04bae4fd64 to your computer and use it in GitHub Desktop.
Save TeddyBear06/cedae273d0c968ae6b14cb04bae4fd64 to your computer and use it in GitHub Desktop.
GitLab Docker installation

🎇 GitLab and GitLab runner using Docker 🎇

⚠️ There are known issues running GitLab/GitLab runner using Docker on Windows, please use GNU/Linux or macOS ⚠️

ℹ️ Run the installation on a brand new host without any previous services running on ports 22, 80 nor 443 ℹ️

🐳 Tested using Docker Desktop 4.4.4 (73704).

A. Map custom domain

[1/1] Add this line to the hosts file:

127.0.0.1 gitlab

B. Create a bridge network

[1/1] Create a network for our conatiners to communicate between each others:

docker network create gitlab-network

C. GitLab container

[1/4] Set GITLAB_HOME env:

export GITLAB_HOME=/srv/gitlab

[2/4] Run GitLab Community Edition:

sudo docker run --detach --hostname gitlab --network gitlab-network --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:latest

⏳ The previous step (step C.2) can take a while (several minutes)... Look at container logs to see the progression.

docker logs -f gitlab

[3/4] Get temporary root password:

sudo docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password

[4/4] Login with username "root" and password as above (step C.3) at http://127.0.0.1

D. GitLab runner

[1/6] Start the runner container:

docker run -d --name gitlab-runner --network gitlab-network --restart always -v /srv/gitlab-runner/config:/etc/gitlab-runner -v /var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-runner:latest

[2/6] Register a runner (if you execute n times this command, it will register n runners):

docker run --rm -it --network gitlab-network -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register

[3/6] Follow steps:

[4/6] Activate "Run untagged jobs" (ex.: http://127.0.0.1/admin/runners/1/edit but do it on each one)

[5/6] Open runner's configuration file:

sudo vim /srv/gitlab-runner/config/config.toml

[6/6] Under [runners.docker] section, add the following (otherwise, the runner cannot resolve http://gitlab/...):

privileged = true
network_mode = "gitlab-network"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment