Setting Up a Local GitLab Server
with Docker Compose on Windows-Based Systems
A step-by-step guide to set up GitLab using Docker Compose on a Windows system and access the GitLab web interface.
Prerequisites
- Docker Desktop installed on Windows
- Docker Compose installed and configured
Step 1: Create a Docker Compose File
- Create a directory for your GitLab setup, e.g.,
C:\Users\YourUsername\gitlab
. - Inside this directory, create a file named
docker-compose.yml
.
docker-compose.yml
Content:
version: '3'
services:
gitlab:
image: gitlab/gitlab-ee:latest
restart: always
hostname: 'gitlab.example.com'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://gitlab.example.com'
ports:
- '80:80'
- '443:443'
- '22:22'
volumes:
- 'gitlab_config:/etc/gitlab'
- 'gitlab_logs:/var/log/gitlab'
- 'gitlab_data:/var/opt/gitlab'
volumes:
gitlab_config:
driver: local
gitlab_logs:
driver: local
gitlab_data:
driver: local
Step 2: Start GitLab Using Docker Compose
- Open PowerShell or Command Prompt.
- Navigate to the directory where
docker-compose.yml
is located. - Run the following command to start GitLab:
docker-compose up -d
Step 3: Verify Container Status
- Check the status of the running containers:
docker-compose ps
You should see an output indicating the GitLab container is up and running.
Step 4: Access GitLab Web Interface
- Open a web browser.
- Navigate to
http://localhost
(orhttps://localhost
if configured for HTTPS). - You should see the GitLab login page.
Step 5: Retrieve the Initial Root Password
- Access the running GitLab container:
docker exec -it gitlab-gitlab-1 bash
- Read the initial root password from the file:
cat /etc/gitlab/initial_root_password
Note: This password is valid only if you have not logged in to the web UI or reset the root password.
Step 6: Login to GitLab
- Use the following credentials to log in:
- Username:
root
- Password: The password retrieved from the previous step.
- Username:
- After logging in, it’s recommended to change the password for security reasons:
- Go to your profile settings and change the password to something secure.
Troubleshooting
- If the password file is missing or invalid, you can reset the root password using the Rails console:
- Access the GitLab container:
docker exec -it gitlab-gitlab-1 bash
- Start the Rails console:
gitlab-rails console
- Reset the password:
user = User.find_by(username: 'root')
user.password = 'new_password'
user.password_confirmation = 'new_password'
user.save!
- Exit the Rails console and the container, then log in with the new password.
Conclusion
By following these steps, you should have a functional GitLab instance running on your Windows machine using Docker Compose. For additional configuration options and troubleshooting, refer to the official Omnibus GitLab documentation.
Join Our Community!
🌟 Get exclusive insights and the latest IT tools and scripts, straight to your inbox.
🔒 We respect your privacy. Unsubscribe at any time.