This README provides instructions for setting up a self-hosted GitLab instance using Docker Compose.
- Docker and Docker Compose installed on your system
- Basic understanding of Docker containers
- Sufficient system resources (recommended: 4+ CPU cores, 8+ GB RAM, 50+ GB storage)
- A server or machine with ports 8929, 443, and 2424 available
- Create a directory for your GitLab installation:
mkdir -p ~/gitlab
cd ~/gitlab- Create a
.envfile to define the GitLab home directory:
echo "GITLAB_HOME=$(pwd)" > .env- Create a
docker-compose.ymlfile with the following content:
services:
gitlab:
image: gitlab/gitlab-ee:16.11.0-ee.0
container_name: gitlab
restart: always
hostname: 'gitlab.example.com'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://gitlab.example.com:8929'
gitlab_rails['gitlab_shell_ssh_port'] = 2424
ports:
- '8929:8929'
- '443:443'
- '2424:22'
volumes:
- '$GITLAB_HOME/config:/etc/gitlab'
- '$GITLAB_HOME/logs:/var/log/gitlab'
- '$GITLAB_HOME/data:/var/opt/gitlab'
shm_size: '256m'- Image: Using GitLab Enterprise Edition version 16.11.0-ee.0
- Hostname: Set to
gitlab.example.com(change as needed) - External URL: Set to
http://gitlab.example.com:8929(change as needed) - Ports:
- Web UI: 8929
- HTTPS: 443
- SSH: 2424 (mapped to internal port 22)
- Volumes:
- Configuration files:
$GITLAB_HOME/config - Log files:
$GITLAB_HOME/logs - Data:
$GITLAB_HOME/data
- Configuration files:
- Shared memory: Set to 256MB
- Launch GitLab with Docker Compose:
docker-compose up -d- Monitor the startup process:
docker-compose logs -fGitLab may take a few minutes to fully initialize on the first run.
-
Once GitLab is running, access it in your browser at:
http://gitlab.example.com:8929(if hostname is configured in your DNS or hosts file)http://localhost:8929(if running locally)
-
For the first login, use the username
rootand the automatically generated password. You can retrieve the initial root password with:
docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_passwordNote: This initial password is valid for 24 hours after installation. Make sure to change it immediately after your first login.
For a production environment, you should:
- Replace
gitlab.example.comwith your actual domain in thedocker-compose.ymlfile - Configure DNS settings to point your domain to the server's IP address
- Consider setting up HTTPS with Let's Encrypt or your own certificates
GitLab's SSH functionality is available on port 2424. To use Git over SSH, you'll need to specify the port:
git clone ssh://git@gitlab.example.com:2424/username/project.gitGitLab automatically creates backups. To create a manual backup:
docker exec -it gitlab gitlab-backup createBackups are stored in /var/opt/gitlab/backups inside the container, which is mapped to $GITLAB_HOME/data/backups on your host.
To update GitLab to a newer version:
- Update the image version in your
docker-compose.yml - Pull the new image and restart:
docker-compose down
docker-compose pull
docker-compose up -d- Container fails to start: Check logs with
docker-compose logs gitlab - Cannot access web UI: Verify port mappings with
docker-compose ps - Performance issues: The default
shm_sizeof 256MB might be insufficient for larger installations; increase as needed - Email not working: Configure SMTP settings in the GitLab configuration
GitLab EE is licensed under the GitLab Enterprise Edition License.