How to Run Gitlab Docker Container in Microsoft Windows

Posted on

How to Run Gitlab Docker Container in Microsoft Windows

Introduction

This is an article for running Gitlab docker container in Microsoft Windows. So, it does not need to install Gitlab directly in the device. Just run a Docker service engine and then run Gitlab service virtually in it. So, instead of using a physical installation directly in the device, just use a running docker container to run Gitlab service virtually.In this article, the explanation for running Gitlab in a running docker container is using a device running using Microsoft Windows.

Preparation

In order to run Gitlab service in a running docker container, there are several preparation steps required to do that. The following are the steps to accomplish it :

  1. First of all, just create a new folder for storing the Gitlab files. As an example, create a folder with the name of ‘Gitlab’. Moreover, as an example in this article, just use the root folder location For creating ‘Gitlab’ folder in ‘C:\Users\Personal\Documents’. As an illustration to show how to do that, just check the content of the following video :

  2. After that, just run Command Prompt. The main purpose to start Windows PowerShell is for setting a Gitlab environment variable. to execute a command to start running Gitlab docker container. Get the path or location of the Gitlab created folder in the previous step. Type the following line in the Windows PowerShell to be able do it. Below is the appearance of the Windows PowerShell :

    Windows PowerShell
    Copyright (C) Microsoft Corporation. All rights reserved.
    
    Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
    
    PS C:\Users\Personal>
    

    In the Windows PowerShell, type : $GITLAB_HOME”C:\Users\Personal\Documents\Gitlab”

    Windows PowerShell
    Copyright (C) Microsoft Corporation. All rights reserved.
    
    Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
    
    PS C:\Users\Personal>$GITLAB_HOME="C:\Users\Personal\Documents\Gitlab"
    PS C:\Users\Personal>
    

    Next step, just type echo $GITLAB_HOME to check the value of the environment variable defined in the above step. It is just to confirm or to recheck whether the ‘Gitlab’ folder is defined correctly or not. Below is the appearance of it :

    Windows PowerShell
    Copyright (C) Microsoft Corporation. All rights reserved.
    
    Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
    
    PS C:\Users\Personal>$GITLAB_HOME="C:\Users\Personal\Documents\Gitlab"
    PS C:\Users\Personal>echo $GITLAB_HOME
    C:\Users\Personal\Documents\Gitlab
    PS C:\Users\Personal>
    

    As for the steps defining GITLAB_HOME environment before, look at the following video as a reference :

Run Docker Service Engine in Microsoft Windows

After successfully done the above preparation, just do the following steps to run Docker service engine as follows :

First of all, the most important thing is to run the Docker service engine. In a device running using Microsoft Windows, normally Docker service engine will run with the help of Docker Desktop Application. It will automatically start the Docker service exist in the list available as a display in the Services window configuration. Just look in the article ‘How to Run Docker Service Engine in Microsoft Windows’ in this link. Furthemore, if it is necessary, update the version first. Read an article with the title of ‘How to Update Docker Desktop in Microsoft Windows’ in this link to do it. If Docker Desktop Application is not available in the device, just install it first. As for installing Docker Desktop Application, just check the article titled ‘How to Install Docker Desktop in Microsoft Windows’ in his link. Take a look in the following video where the content is showing how to do it :

Run Gitlab Docker Container in Microsoft Windows

Finally, the last part will be the part to run the Gitlab Docker container. Just perform the following steps to do that :

  1. Next, after successfully running Docker service engine, go back to the Command Prompt. Type the following command to run a new Gitlab docker container :

    docker run --detach --hostname gitlab.example.com --publish 443:443 --publish 80:80 --publish 22:22 --name gitlab --restart always --volume $GITLAB_HOME/log:/var/log/gitlab --volume $GITLAB_HOME/data:/var/opt/gitlab --shm-size 512m gitlab/gitlab-ee:latest

    The above command execution for the first time will download the latest version of Gitlab EE Docker image. After that, it will run a new Docker container using that Docker image. It will have the hostname of ‘gitlab.example.com’. Also, the HTTP service running in por 443 along with the Gitlab service will be mapped into port 443. So, an incoming request to port 443 will be passed to Gitlab service. It will also have the same condition with the other published port in port 80 representing HTTP service along with port 22 for SSH service. Another parameter is just defining volume mapping so that log ad data directory will be mapped to the Gitlab location path directory in the host running the Docker container. Check out the following content video to look at it :

  2. Finally, after running the Gitlab Docker container, just access it via web browser. But before that, make sure that the status of the Gitlab Docker container is running with ‘healthy’ status. Following after, just run any web browser available and then type ‘localhost’ in the URL address bar. Follow the content of the following video to take a grasp on how to do it :

  3. Last but not least, login to the Gitlab. Before that, get the default password generated for root user account. Access the Gitlab Docker container by typing the following command in the Windows PowerShell :

    PS C:\Users\Personal>docker exec -it gitlab /bin/bash
    root@gitlab:/# cat /etc/gitlab/initial_root_password
    #WARNING: This value is valid only in the following condiions
    # 1. If provided manually (either via 'GITLAB_ROOT_PASSWORD' environment variable or via 'gitlab_rails['initial_root_password']' etting n 'GitLab.rb', it was provided before database was seeded for the first time (usually, the first reconfigure run).
    # 2. Password hasn't been changed manually, either via UI or via command line.
    # If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.
    
    Password : kV71TBa0X51kZBRIuJV/obXXzeW43kZvnm8tu*UrLI=
    #NOTE : This file will be automatically deleted in the first reconfigure run after 24 hours.
    root@gitlab:/#
    

    Using the above default password of root user account, enter it in the Gitlab login page. So, enter ‘root’ in the Username or primary email textfield. Following after, enter ‘kV71TBa0X51kZBRIuJV/obXXzeW43kZvnm8tu*UrLI=’ in the Password textfield. For more clearance, just check in the following video content :

Leave a Reply