How To: Setup a Local GitLab Server with Docker Compose on Windows

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

  1. Create a directory for your GitLab setup, e.g., C:\Users\YourUsername\gitlab.
  2. 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

  1. Open PowerShell or Command Prompt.
  2. Navigate to the directory where docker-compose.yml is located.
  3. Run the following command to start GitLab:
docker-compose up -d

Step 3: Verify Container Status

  1. 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

  1. Open a web browser.
  2. Navigate to http://localhost (or https://localhost if configured for HTTPS).
  3. You should see the GitLab login page.

Step 5: Retrieve the Initial Root Password

  1. Access the running GitLab container:
docker exec -it gitlab-gitlab-1 bash
  1. 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

  1. Use the following credentials to log in:
    • Username: root
    • Password: The password retrieved from the previous step.
  2. 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:
    1. Access the GitLab container:
docker exec -it gitlab-gitlab-1 bash
  1. Start the Rails console:
gitlab-rails console
  1. Reset the password:
user = User.find_by(username: 'root')
user.password = 'new_password'
user.password_confirmation = 'new_password'
user.save!
  1. 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.

Andy N

Information Technology Support Analyst with over seven years of experience (in the telecommunications and manufacturing industries) ranging from user support to administering and maintaining core IT systems.

Related Posts

×