Skip to content

Instantly share code, notes, and snippets.

@kalw
Last active October 20, 2025 15:34
Show Gist options
  • Select an option

  • Save kalw/fd1570016262debdf6476ea07b58cfe2 to your computer and use it in GitHub Desktop.

Select an option

Save kalw/fd1570016262debdf6476ea07b58cfe2 to your computer and use it in GitHub Desktop.
gitlab et runner docker compose
services:
gitlab:
image: gitlab/gitlab-ee:latest
restart: always
ports:
- "24:22"
- "80:80"
- "443:443"
volumes:
- gitlab-data:/var/opt/gitlab
- gitlab-logs:/var/log/gitlab
- gitlab-config:/etc/gitlab
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://gitlab.127.0.0.1.nip.io/';
gitlab_rails['lfs_enabled'] = true;
gitlab_rails['initial_shared_runners_registration_token'] = "${RUNNER_TOKEN}"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/-/health"]
interval: 1m30s
timeout: 10s
retries: 3
start_period: 40s
start_interval: 5s
runner:
image: gitlab/gitlab-runner:ubuntu
restart: always
depends_on:
gitlab:
condition: service_healthy
volumes:
- /var/run/docker.sock:/var/run/docker.sock
external_links:
- gitlab:gitlab.127.0.0.1.nip.io
entrypoint: /bin/sh -c "((gitlab-runner list |grep $$(hostname) )|| gitlab-runner register --leave-runner --non-interactive --name $$(hostname) --url 'http://gitlab/' --registration-token ${RUNNER_TOKEN} --executor "docker" --docker-image alpine:latest --tag-list docker --docker-privileged=false --run-untagged=true --docker-links='gitlab:gitlab.127.0.0.1.nip.io' --locked='false'; exit)&& gitlab-runner run"
volumes:
gitlab-data:
gitlab-logs:
gitlab-config:
@kalw
Copy link
Author

kalw commented Oct 7, 2025

export RUNNER_TOKEN="$(openssl rand -base64 32)" # generate runner registration token
docker-compose -f gitlab-ee.yaml up -d # start the instance and the runner
docker-compose -f gitlab-ee.yaml exec gitlab bash -c "grep -e ^Password /etc/gitlab/initial_root_password" # get initial root passwd
docker-compose -f gitlab-ee.yaml down -v && docker-compose -f gitlab-ee.yaml up -d # restart fresh

@amoevi
Copy link

amoevi commented Oct 7, 2025

- RUNNER_TOKEN="$(openssl rand 32 -base64)" docker-compose -f gitlab-ee.yaml up -d
+ RUNNER_TOKEN="$(openssl rand -base64 32)" docker-compose -f gitlab-ee.yaml up -d
docker-compose -f gitlab-ee.yaml exec gitlab bash -c "grep -e ^Password /etc/gitlab/initial_root_password"

The rand command requires the number of bytes after the options : https://docs.openssl.org/1.0.2/man1/rand/

@kalw
Copy link
Author

kalw commented Oct 7, 2025

🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment