A Docker Compose stack for running GitLab CE with GitLab Runner locally. Perfect for CI/CD experiments, testing GitLab features, and development workflows.
- GitLab CE - Full GitLab instance running locally
- GitLab Runner - Pre-configured with 4 runners (general, python, node, php)
- Traefik Proxy - Reverse proxy with HTTPS via mkcert
- Automated initialization - Group, projects, users, and runners created on first startup
- Docker-in-Docker: Full support for container builds in CI/CD
- Optional HTTPS - Traefik reverse proxy with mkcert certificates
- SSH & HTTPS Access: Both protocols configured out of the box
- Docker: Version 20.10 or higher
- Docker Compose: Version 2.0 or higher
- Available Ports: 8550 (HTTP), 443 (HTTPS), 2222 (SSH), 8080 (Traefik Dashboard), 9252 (metrics)
- Memory: Minimum 4GB RAM recommended
- Storage: At least 10GB free disk space
┌──────────────────────────────────────────────────────┐
│ Docker Network │
│ (gitlab-network: 172.31.0.0/16) │
├──────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────┐ │
│ │ Traefik Proxy │ │
│ │ (172.31.0.10) │ │
│ │ │ │
│ │ - HTTP → HTTPS │ │
│ │ - Auto SSL/TLS │ │
│ │ - Load Balancing │ │
│ └──────────┬──────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────┐ ┌──────────────────┐ │
│ │ GitLab CE │ │ GitLab Runner │ │
│ │ (172.31.0.2) │◄──────┤ (172.31.0.3) │ │
│ │ │ │ │ │
│ │ - Web UI (80) │ │ - 4 Runners: │ │
│ │ - Git SSH (2222) │ │ • General │ │
│ │ - API │ │ • Python 3.12 │ │
│ │ - 6 Demo Projects │ │ • Node.js 20 │ │
│ │ │ │ • PHP 8.2 │ │
│ └─────────────────────┘ └──────────────────┘ │
└──────────────────────────────────────────────────────┘
Note: The diagram shows the full architecture with Traefik. In standalone mode (default), only GitLab CE and GitLab Runner are started.
# Clone the repository
git clone https://github.com/bulletinmybeard/local-gitlab-ce-stack.git
cd local-gitlab-ce-stack
# Setup environment
cp .env.sample .env
# Edit .env and set GITLAB_ROOT_PASSWORD./scripts/gitlab/start-gitlab.shFirst startup takes about 2-5 minutes. The script will:
- Create a Docker network
- Spin up GitLab CE and GitLab Runner containers
- Wait for services to be healthy
- Initialize demo projects and runners
- Configure SSH access
- GitLab URL: http://localhost:8550
- SSH: git@localhost:2222
- Username: root
- Password: Check your
.envfile - Demo User: johndoe (password in
.env)
The stack supports two modes of operation:
Access GitLab via http://localhost:8550 - no Traefik, no HTTPS. This is the simplest setup.
./scripts/gitlab/start-gitlab.sh
./scripts/gitlab/stop-gitlab.sh
./scripts/gitlab/clean-gitlab-setup.shAccess GitLab via https://gitlab.localhost with Traefik reverse proxy and mkcert SSL certificates.
Requires additional setup - see Traefik Configuration below.
./scripts/gitlab/start-gitlab.sh --traefik
./scripts/gitlab/stop-gitlab.sh --traefik
./scripts/gitlab/clean-gitlab-setup.sh --traefikpython-test- Python project templatephp-test- PHP project templatenodejs-test- Node.js project templateext-test- External integration testingint-test- Internal integration testingdemo- General demo project
| Runner | Tags | Docker Image | Purpose |
|---|---|---|---|
| general-runner | docker, general, default | alpine:latest | General purpose CI/CD |
| python-runner | python, python3 | python:3.12 | Python applications |
| node-runner | node, nodejs | node:20 | Node.js applications |
| php-runner | php, php8, laravel | php:8.2-cli | PHP applications |
- root - Administrator account
- johndoe - Demo user with full access to demo-group
GITLAB_ROOT_PASSWORD- Root user passwordDEMO_USERNAME- Demo user usernameDEMO_USER_PASSWORD- Demo user password
SSH keys are automatically generated on first startup and copied to ~/.ssh/gitlab-local. To regenerate keys, run ./scripts/gitlab/generate-ssh-keys.sh.
# Check container status
docker ps -a
# View GitLab logs
docker logs gitlab
# Check GitLab health
docker exec gitlab gitlab-ctl status# Verify GitLab is healthy
docker inspect gitlab | grep -A5 Health
# Check if port 8550 is available
lsof -i :8550# Regenerate SSH client config
./docker/gitlab/scripts/setup-ssh-client.sh
# Test SSH connection
ssh -T -p 2222 git@localhost# Stop and clean all resources
./scripts/gitlab/clean-gitlab-setup.sh
# This will remove:
# - All containers
# - Generated credentials
# - SSH configurations
# - Docker volumesSSH uses port 2222 to avoid conflicts with your system's SSH daemon:
# Using GIT_SSH_COMMAND to specify the port
GIT_SSH_COMMAND="ssh -p 2222" git clone git@localhost:demo-group/python-test.git
# Or configure SSH once in ~/.ssh/config (see below)
git clone git@gitlab-local:demo-group/python-test.gitTip: Add this to ~/.ssh/config for easier cloning:
Host gitlab-local
HostName localhost
Port 2222
User git
IdentityFile ~/.ssh/gitlab-local
# Using access token (recommended)
git clone http://root:${TOKEN}@localhost:8550/demo-group/python-test.git
# Using password
git clone http://root:${PASSWORD}@localhost:8550/demo-group/python-test.gitCreate .gitlab-ci.yml in your project:
stages:
- test
- build
test-python:
stage: test
tags:
- python
script:
- python --version
- pip install pytest
- pytest
build-docker:
stage: build
tags:
- docker
script:
- docker build -t myapp .Note: This section only applies when using Traefik mode (--traefik flag).
Traefik provides:
- Automatic HTTPS with locally trusted certificates
- Clean URLs (
https://gitlab.localhost) - Built-in dashboard for monitoring
- Load balancing and health checks
Add these entries to your /etc/hosts file:
127.0.0.1 gitlab.localhost
127.0.0.1 traefik.localhostThis project uses mkcert to generate locally trusted SSL certificates. This means no browser warnings!
Install mkcert first:
# macOS
brew install mkcert
brew install nss # if you use Firefox
# Linux - download from https://github.com/FiloSottile/mkcert/releasescd traefik-data/certs && ./setup-mkcert.shThis will:
- Install the mkcert root CA in your system trust store
- Generate certificates for localhost, gitlab.localhost, traefik.localhost
- Make them trusted by your browser automatically
To regenerate certificates (e.g., after changing hostnames in .env):
rm -f traefik-data/certs/localhost.*
cd traefik-data/certs && ./setup-mkcert.sh
docker compose restart traefik-gitlabAccess the Traefik dashboard at https://traefik.localhost to:
- View active routes and services
- Monitor health checks
- Debug routing issues
- View real-time metrics
MIT License - see the LICENSE file for details.