docker.recipes

GitLab CE Complete Stack

advanced

Self-hosted GitLab Community Edition with integrated CI/CD and container registry.

Overview

GitLab Community Edition is a comprehensive DevOps platform that combines source code management, continuous integration/continuous deployment (CI/CD), container registry, and project management in a single application. Originally launched in 2011 as an open-source alternative to proprietary Git hosting solutions, GitLab CE has evolved into a complete software development lifecycle platform that rivals enterprise solutions while remaining free and self-hosted. Unlike cloud-based alternatives, GitLab CE gives organizations complete control over their code, data, and development processes. This stack combines GitLab CE with PostgreSQL for robust data storage, Redis for high-performance caching and session management, and GitLab Runner for executing CI/CD pipelines. PostgreSQL handles GitLab's complex relational data including user accounts, project metadata, merge requests, and issue tracking, while Redis accelerates the platform by caching frequently accessed data and managing real-time features like notifications and live updates. GitLab Runner provides the compute engine for automated testing, building, and deployment workflows, creating a complete DevOps automation environment. This configuration is ideal for development teams, startups, and organizations seeking enterprise-grade DevOps capabilities without vendor lock-in or subscription costs. Teams migrating from GitHub Enterprise, Bitbucket Server, or Jenkins-based workflows will find GitLab CE provides integrated functionality that eliminates the need for multiple disparate tools. The stack is particularly valuable for security-conscious organizations requiring on-premises code hosting and for teams implementing GitOps practices with built-in container registry and Kubernetes integration.

Key Features

  • Complete Git repository hosting with advanced branch protection and merge request workflows
  • Integrated CI/CD pipelines with Docker-based runners and parallel job execution
  • Built-in container registry supporting Docker images with vulnerability scanning
  • Comprehensive project management including issues, milestones, epics, and Kanban boards
  • Auto DevOps capabilities with automatic testing, security scanning, and deployment
  • Wiki and documentation system with Markdown support and version control
  • Advanced user management with LDAP/SAML integration and role-based permissions
  • Built-in monitoring and analytics with deployment frequency and lead time metrics

Common Use Cases

  • 1Enterprise teams transitioning from GitHub Enterprise or Bitbucket Server to self-hosted Git
  • 2Development organizations implementing comprehensive DevSecOps with integrated security scanning
  • 3Startups requiring complete DevOps platform without per-user licensing costs
  • 4Educational institutions teaching software development with full project lifecycle tools
  • 5Open source projects needing advanced CI/CD capabilities beyond basic Git hosting
  • 6Companies in regulated industries requiring on-premises code and artifact storage
  • 7Teams practicing GitOps with Kubernetes deployments and infrastructure as code

Prerequisites

  • Minimum 8GB RAM recommended (GitLab CE requires 4GB+ alone)
  • At least 20GB available disk space for GitLab data, logs, and container registry
  • Docker and Docker Compose installed with sufficient permissions
  • Ports 80, 443, 2224, and 5050 available for web interface, SSH, and registry access
  • Basic understanding of Git workflows and CI/CD concepts
  • SMTP server credentials if email notifications are required

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 gitlab:
3 image: gitlab/gitlab-ce:latest
4 container_name: gitlab
5 hostname: gitlab.local
6 environment:
7 GITLAB_OMNIBUS_CONFIG: |
8 external_url '${GITLAB_EXTERNAL_URL}'
9 gitlab_rails['gitlab_shell_ssh_port'] = 2224
10 registry_external_url '${REGISTRY_EXTERNAL_URL}'
11 gitlab_rails['smtp_enable'] = true
12 gitlab_rails['smtp_address'] = "${SMTP_HOST}"
13 gitlab_rails['smtp_port'] = ${SMTP_PORT}
14 gitlab_rails['smtp_user_name'] = "${SMTP_USER}"
15 gitlab_rails['smtp_password'] = "${SMTP_PASSWORD}"
16 gitlab_rails['smtp_domain'] = "${SMTP_DOMAIN}"
17 gitlab_rails['smtp_authentication'] = "login"
18 gitlab_rails['smtp_enable_starttls_auto'] = true
19 prometheus_monitoring['enable'] = false
20 puma['worker_processes'] = 2
21 sidekiq['max_concurrency'] = 10
22 ports:
23 - "80:80"
24 - "443:443"
25 - "2224:22"
26 - "5050:5050"
27 volumes:
28 - gitlab-config:/etc/gitlab
29 - gitlab-logs:/var/log/gitlab
30 - gitlab-data:/var/opt/gitlab
31 shm_size: '256m'
32 networks:
33 - gitlab-network
34 restart: unless-stopped
35
36 gitlab-runner:
37 image: gitlab/gitlab-runner:latest
38 container_name: gitlab-runner
39 volumes:
40 - gitlab-runner-config:/etc/gitlab-runner
41 - /var/run/docker.sock:/var/run/docker.sock
42 depends_on:
43 - gitlab
44 networks:
45 - gitlab-network
46 restart: unless-stopped
47
48volumes:
49 gitlab-config:
50 gitlab-logs:
51 gitlab-data:
52 gitlab-runner-config:
53
54networks:
55 gitlab-network:
56 driver: bridge

.env Template

.env
1# GitLab CE Complete
2GITLAB_EXTERNAL_URL=http://gitlab.local
3REGISTRY_EXTERNAL_URL=http://registry.gitlab.local:5050
4
5# SMTP Settings
6SMTP_HOST=smtp.example.com
7SMTP_PORT=587
8SMTP_USER=gitlab@example.com
9SMTP_PASSWORD=smtp_password
10SMTP_DOMAIN=example.com

Usage Notes

  1. 1GitLab at http://localhost
  2. 2Initial root password in /etc/gitlab/initial_root_password
  3. 3Register runner: gitlab-runner register
  4. 4Container registry at :5050
  5. 5Requires 4GB+ RAM minimum

Individual Services(2 services)

Copy individual services to mix and match with your existing compose files.

gitlab
gitlab:
  image: gitlab/gitlab-ce:latest
  container_name: gitlab
  hostname: gitlab.local
  environment:
    GITLAB_OMNIBUS_CONFIG: |
      external_url '${GITLAB_EXTERNAL_URL}'
      gitlab_rails['gitlab_shell_ssh_port'] = 2224
      registry_external_url '${REGISTRY_EXTERNAL_URL}'
      gitlab_rails['smtp_enable'] = true
      gitlab_rails['smtp_address'] = "${SMTP_HOST}"
      gitlab_rails['smtp_port'] = ${SMTP_PORT}
      gitlab_rails['smtp_user_name'] = "${SMTP_USER}"
      gitlab_rails['smtp_password'] = "${SMTP_PASSWORD}"
      gitlab_rails['smtp_domain'] = "${SMTP_DOMAIN}"
      gitlab_rails['smtp_authentication'] = "login"
      gitlab_rails['smtp_enable_starttls_auto'] = true
      prometheus_monitoring['enable'] = false
      puma['worker_processes'] = 2
      sidekiq['max_concurrency'] = 10
  ports:
    - "80:80"
    - "443:443"
    - "2224:22"
    - "5050:5050"
  volumes:
    - gitlab-config:/etc/gitlab
    - gitlab-logs:/var/log/gitlab
    - gitlab-data:/var/opt/gitlab
  shm_size: 256m
  networks:
    - gitlab-network
  restart: unless-stopped
gitlab-runner
gitlab-runner:
  image: gitlab/gitlab-runner:latest
  container_name: gitlab-runner
  volumes:
    - gitlab-runner-config:/etc/gitlab-runner
    - /var/run/docker.sock:/var/run/docker.sock
  depends_on:
    - gitlab
  networks:
    - gitlab-network
  restart: unless-stopped

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 gitlab:
5 image: gitlab/gitlab-ce:latest
6 container_name: gitlab
7 hostname: gitlab.local
8 environment:
9 GITLAB_OMNIBUS_CONFIG: |
10 external_url '${GITLAB_EXTERNAL_URL}'
11 gitlab_rails['gitlab_shell_ssh_port'] = 2224
12 registry_external_url '${REGISTRY_EXTERNAL_URL}'
13 gitlab_rails['smtp_enable'] = true
14 gitlab_rails['smtp_address'] = "${SMTP_HOST}"
15 gitlab_rails['smtp_port'] = ${SMTP_PORT}
16 gitlab_rails['smtp_user_name'] = "${SMTP_USER}"
17 gitlab_rails['smtp_password'] = "${SMTP_PASSWORD}"
18 gitlab_rails['smtp_domain'] = "${SMTP_DOMAIN}"
19 gitlab_rails['smtp_authentication'] = "login"
20 gitlab_rails['smtp_enable_starttls_auto'] = true
21 prometheus_monitoring['enable'] = false
22 puma['worker_processes'] = 2
23 sidekiq['max_concurrency'] = 10
24 ports:
25 - "80:80"
26 - "443:443"
27 - "2224:22"
28 - "5050:5050"
29 volumes:
30 - gitlab-config:/etc/gitlab
31 - gitlab-logs:/var/log/gitlab
32 - gitlab-data:/var/opt/gitlab
33 shm_size: '256m'
34 networks:
35 - gitlab-network
36 restart: unless-stopped
37
38 gitlab-runner:
39 image: gitlab/gitlab-runner:latest
40 container_name: gitlab-runner
41 volumes:
42 - gitlab-runner-config:/etc/gitlab-runner
43 - /var/run/docker.sock:/var/run/docker.sock
44 depends_on:
45 - gitlab
46 networks:
47 - gitlab-network
48 restart: unless-stopped
49
50volumes:
51 gitlab-config:
52 gitlab-logs:
53 gitlab-data:
54 gitlab-runner-config:
55
56networks:
57 gitlab-network:
58 driver: bridge
59EOF
60
61# 2. Create the .env file
62cat > .env << 'EOF'
63# GitLab CE Complete
64GITLAB_EXTERNAL_URL=http://gitlab.local
65REGISTRY_EXTERNAL_URL=http://registry.gitlab.local:5050
66
67# SMTP Settings
68SMTP_HOST=smtp.example.com
69SMTP_PORT=587
70SMTP_USER=gitlab@example.com
71SMTP_PASSWORD=smtp_password
72SMTP_DOMAIN=example.com
73EOF
74
75# 3. Start the services
76docker compose up -d
77
78# 4. View logs
79docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/gitlab-ce-complete/run | bash

Troubleshooting

  • GitLab container exits with 'not enough shared memory': Increase shm_size to 512m or higher in docker-compose.yml
  • 502 Bad Gateway on initial startup: Wait 5-10 minutes for GitLab's internal services to fully initialize before accessing web interface
  • GitLab Runner registration fails with SSL errors: Use gitlab.local hostname or configure proper SSL certificates in GitLab configuration
  • Container registry push fails with authentication errors: Ensure registry_external_url matches your domain and GitLab is fully started
  • High memory usage causing system slowdown: Reduce puma worker_processes and sidekiq max_concurrency in GitLab configuration
  • SSH clone fails on port 2224: Verify SSH key is added to GitLab profile and git remote URL uses correct port

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space