GitLab EE Basic Docker container setup - Jorge-Dacal/devonfw-shop-floor GitHub Wiki

[Under construction]


The purpose of the present document is to provide the steps carried out to setup a basic GitLab Docker container.

Introduction

GitLab is basically a Git server, which also integrates additional features to work for the whole SDLC & Operations. (Please see GitLab)

There are three main GitLab products:

  • Community Edition CE

  • Enterprise Edition Starter EES (or simply EE)

  • Enterprise Edition Premium EEP (or simply EP)

The current scenario has been implemented:

  • In Windows 10

  • Using GitLab EE product

  • With both ways: Running a Docker image from Docker, and using a Docker Compose

  • Using CMDR. (CMD or PowerShell would also be valid)

Aditional documentation:

Prerequisites

  • Docker Engine up & running

  • Docker Compose installed

Procedure

Docker image

Step 1: Download GitLab EE Docker image from Docker Hub

The appropriate Docker pull command can be found at this link:

docker pull gitlab/gitlab-ee

By default, the above command will retrieve from Docker Hub the gitlab-ee image tagged as later.

The download of the image could take several minutes:

C:\Users\ctorresg
λ docker pull gitlab/gitlab-ee
Using default tag: latest
latest: Pulling from gitlab/gitlab-ee
9fb6c798fa41: Already exists
3b61febd4aef: Already exists
9d99b9777eb0: Already exists
d010c8cf75d7: Already exists
7fac07fb303e: Already exists
bc01db990221: Pull complete
7539d2ccc8d3: Pull complete
9b4ad485b37f: Pull complete
1f064be08b08: Pull complete
09c20f2fa048: Pull complete
aae959883960: Downloading [=====================>                             ]  173.5MB/412.6MB

The expected result must be something similar to:

Using default tag: latest
latest: Pulling from gitlab/gitlab-ee
9fb6c798fa41: Already exists
3b61febd4aef: Already exists
9d99b9777eb0: Already exists
d010c8cf75d7: Already exists
7fac07fb303e: Already exists
bc01db990221: Pull complete
7539d2ccc8d3: Pull complete
9b4ad485b37f: Pull complete
1f064be08b08: Pull complete
09c20f2fa048: Pull complete
aae959883960: Pull complete
Digest: sha256:54e160701cb0e14505cda1dfe82327d8245b2750674e07288cd9a2d2a8d75d75
Status: Downloaded newer image for gitlab/gitlab-ee:latest

Step 2: Check that the image is available in your local docker registry

docker images

Above docker command must return a list of docker images, in which is included our gitlab/gitlab-ee:

REPOSITORY          TAG     IMAGE ID        CREATED     SIZE
gitlab/gitlab-ee    latest  a67660695a96    5 days ago  1.41GB

Step 3: Create and run a new container with the docker run command

docker run --detach --name gitlab-ee --hostname mygitlab.com --publish 8888:8888 --publish 22:22 --env GITLAB_OMNIBUS_CONFIG="external_url 'http://mygitlab.com:8888'; gitlab_rails['gitlab_shell_ssh_port']=22;" gitlab/gitlab-ee

To stand out:

  • --detach creates & runs the container in background and print container id (see docker run --help)

  • --name gitlab-ee will be the name of the container

  • --hostname mygitlab.com will be the name of our host for this scenario. Notice that this host name must be delcared in the hosts file of the machine. (The host name must be provided by the company or organization)

  • --publish 8888:8888 --publish 22:22 are the TCP/SSH ports

  • --env GITLAB_OMNIBUS_CONFIG="external_url 'http://mygitlab.com:8888'; gitlab_rails['gitlab_shell_ssh_port']=22;" Are the two GitLab env. variables that must be specified in order for the application to be accesible through its hostname.

  • gitlab/gitlab-ee name of the image from which the container will be created

Important

  • Notice that an external_url with https raises problems with nginx. (nginx issues pending to be resolved)

  • The creation of the GitLab container is quite heavy and therefore it could take several minutes.

The command returns the control almost immediately, however the container is being created in background:

C:\Users\ctorresg
λ docker run --detach --name gitlab-ee --hostname mygitlab.com --publish 8888:8888 --publish 22:22 --env GITLAB_OMNIBUS_CONFIG="external_url 'http://mygitlab.com:8888'; gitlab_rails['gitlab_shell_ssh_port']=22;" gitlab/gitlab-ee 438e80e17460413b3c5ae358d58b12366d1bd4da044c526a05e9f612d2653431

C:\Users\ctorresg

Step 4: Check & confirm that the new container is up & running

docker ps
CONTAINER ID    IMAGE               COMMAND             CREATED         STATUS                  PORTS                                                         NAMES
438e80e17460    gitlab/gitlab-ee    "/assets/wrapper"   3 minutes ago   Up 3 minutes (healthy)  80/tcp, 0.0.0.0:22->22/tcp, 0.0.0.0:8888->8888/tcp, 443/tcp   gitlab-ee

Step 5: Check the GitLab server is up & running

Go to http://mygitlab.com:8888 or localhost:8888 or 127.0.0.1:8888

server up&running

Docker compose

The basic docker-compose.yml (or yaml) template has been obtained from GitLab Documentation.

Basic template:

web:
  image: 'gitlab/gitlab-ce:latest'
  restart: always
  hostname: 'gitlab.example.com'
  environment:
    GITLAB_OMNIBUS_CONFIG: |
      external_url 'https://gitlab.example.com'
      # Add any other gitlab.rb configuration here, each on its own line
  ports:
    - '80:80'
    - '443:443'
    - '22:22'
  volumes:
    - '/srv/gitlab/config:/etc/gitlab'
    - '/srv/gitlab/logs:/var/log/gitlab'
    - '/srv/gitlab/data:/var/opt/gitlab'

Step 1: Create a yaml file named docker-compose.yml (or yaml)

The content of our docker-compose file must be:

web:
  image: 'gitlab/gitlab-ee'
  restart: always
  hostname: 'mygitlab.com'
  container_name: gitlab-ee
  environment:
    GITLAB_OMNIBUS_CONFIG: |
      external_url 'http://mygitlab.com:8888'
      gitlab_rails['gitlab_shell_ssh_port']=22
  ports:
    - '8888:8888'
    - '22:22'

Notice that our yml file has been created by modifying the original GitLab template.

To stand out:

  • the hostname and ports have been changed accordingly to our application (should be provided by the company or organization)

  • container_name has been added in order to have a readable and unique container name

  • external_url has been changed from https to http in order to avoid issues with nginx (nginx issues pending to be resolved).

  • volumes have been removed because those are the default ones used by the container, and are not required to be explicitly specified

Step 2: Run docker-compose command

The docker-compose command must be executed in the same directory where our yaml file is located

docker-compose up -d

The command returns the control almost immediately, however the container is being created in background.

The result must be something similar to:

λ docker-compose up -d
Creating gitlab-ee ...
Creating gitlab-ee ... done

Step 3: Check & confirm that the new container is up & running

docker ps
CONTAINER ID    IMAGE               COMMAND             CREATED         STATUS                  PORTS                                                         NAMES
da6b651a594e    gitlab/gitlab-ee    "/assets/wrapper"   3 minutes ago   Up 3 minutes (healthy)  80/tcp, 0.0.0.0:22->22/tcp, 0.0.0.0:8888->8888/tcp, 443/tcp   gitlab-ee

Step 4: Check the GitLab server is up & running

Go to http://mygitlab.com:8888 or localhost:8888 or 127.0.0.1:8888

server up&running
⚠️ **GitHub.com Fallback** ⚠️