docker.recipes

GitLab CE

advanced

Self-hosted GitLab Community Edition with CI/CD.

Overview

GitLab Community Edition is a comprehensive DevOps platform that revolutionizes software development by consolidating the entire development lifecycle into a single, self-hosted application. Originally created by GitLab Inc. in 2011, GitLab CE has evolved from a simple Git repository manager into a complete DevOps solution that includes version control, issue tracking, continuous integration/continuous deployment, container registry, security scanning, and project management tools. Unlike fragmented toolchains that require multiple vendors and complex integrations, GitLab provides everything development teams need under one roof. This Docker deployment creates a fully functional GitLab CE instance that handles everything from source code management to automated deployments. GitLab's omnibus package includes PostgreSQL database, Redis cache, Nginx web server, and Gitaly Git RPC service, all orchestrated within a single container. The configuration enables SSH access on port 2224, web interface on standard HTTP/HTTPS ports, and includes built-in CI/CD runners that can execute pipelines immediately after setup. The shared memory allocation of 256MB ensures optimal performance for Git operations and background processing tasks. This stack is ideal for organizations seeking complete control over their DevOps infrastructure without vendor lock-in. Development teams, startups building their first CI/CD pipeline, enterprises requiring security compliance, and educational institutions teaching modern software development practices will find GitLab CE's integrated approach eliminates the complexity of managing separate tools for code review, testing, deployment, and monitoring. The self-hosted nature provides complete data sovereignty while the Community Edition offers enterprise-grade features without licensing costs.

Key Features

  • Complete Git repository management with advanced branching strategies and merge request workflows
  • Built-in CI/CD pipelines with Docker executor support and Auto DevOps capabilities
  • Integrated container registry for storing and managing Docker images within the same platform
  • Security scanning including Static Application Security Testing (SAST) and Dependency Scanning
  • Issue tracking with Kanban boards, milestones, and sprint planning tools
  • Wiki documentation system with Markdown support and version control
  • Code review system with inline comments, approval workflows, and merge request templates
  • Package registry supporting npm, Maven, NuGet, and other package formats

Common Use Cases

  • 1Software development teams migrating from GitHub or Bitbucket seeking integrated CI/CD without third-party tools
  • 2Startups building their first DevOps pipeline who need everything from code hosting to deployment automation
  • 3Educational institutions teaching modern software development practices in a controlled environment
  • 4Open source projects requiring robust issue tracking, documentation, and contributor management
  • 5Small to medium enterprises needing security scanning and compliance reporting for internal applications
  • 6Development agencies managing multiple client projects with separate repositories and deployment pipelines
  • 7Research organizations requiring complete audit trails and data sovereignty for sensitive code projects

Prerequisites

  • Minimum 4GB RAM with 8GB+ recommended for smooth GitLab omnibus operation and CI/CD execution
  • Docker Engine 20.10+ with compose plugin for proper container orchestration and volume management
  • Available ports 80, 443, and 2224 for web interface and SSH Git operations
  • Understanding of Git workflows, merge requests, and basic CI/CD pipeline concepts
  • Administrative access to modify /etc/hosts file or DNS records for hostname resolution
  • At least 20GB available disk space for GitLab data, repositories, and CI/CD artifacts

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 restart: unless-stopped
6 hostname: gitlab.local
7 environment:
8 GITLAB_OMNIBUS_CONFIG: |
9 external_url 'http: //gitlab.local'
10 gitlab_rails['gitlab_shell_ssh_port'] = 2224
11 volumes:
12 - gitlab_config:/etc/gitlab
13 - gitlab_logs:/var/log/gitlab
14 - gitlab_data:/var/opt/gitlab
15 ports:
16 - "80:80"
17 - "443:443"
18 - "2224:22"
19 shm_size: '256m'
20
21volumes:
22 gitlab_config:
23 gitlab_logs:
24 gitlab_data:

.env Template

.env
1# Access with root user, check initial password:
2# docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password

Usage Notes

  1. 1Docs: https://docs.gitlab.com/
  2. 2First start takes 5-10 minutes to initialize
  3. 3Get root password: docker exec gitlab grep 'Password:' /etc/gitlab/initial_root_password
  4. 4Add gitlab.local to /etc/hosts pointing to localhost
  5. 5CI/CD, container registry, issue tracking, wiki included
  6. 6Requires 4GB+ RAM for smooth operation

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 restart: unless-stopped
8 hostname: gitlab.local
9 environment:
10 GITLAB_OMNIBUS_CONFIG: |
11 external_url 'http://gitlab.local'
12 gitlab_rails['gitlab_shell_ssh_port'] = 2224
13 volumes:
14 - gitlab_config:/etc/gitlab
15 - gitlab_logs:/var/log/gitlab
16 - gitlab_data:/var/opt/gitlab
17 ports:
18 - "80:80"
19 - "443:443"
20 - "2224:22"
21 shm_size: '256m'
22
23volumes:
24 gitlab_config:
25 gitlab_logs:
26 gitlab_data:
27EOF
28
29# 2. Create the .env file
30cat > .env << 'EOF'
31# Access with root user, check initial password:
32# docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password
33EOF
34
35# 3. Start the services
36docker compose up -d
37
38# 4. View logs
39docker 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/run | bash

Troubleshooting

  • 502 Bad Gateway on first access: GitLab takes 5-10 minutes to fully initialize all services, wait for complete startup
  • SSH Git operations failing on port 22: GitLab SSH is mapped to port 2224, configure Git remote URLs accordingly
  • Unable to login with root user: Extract initial password using 'docker exec gitlab grep Password: /etc/gitlab/initial_root_password'
  • GitLab web interface shows hostname mismatch: Add 'gitlab.local' entry to /etc/hosts pointing to 127.0.0.1
  • CI/CD runners showing as unavailable: Check container resources and restart GitLab if memory usage exceeds available RAM
  • Container fails to start with permission errors: Ensure Docker daemon has proper permissions to create and mount volumes

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