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.
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)
-
Docker Engine up & running
-
Docker Compose installed
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
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
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 (seedocker 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
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
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'
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
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
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
Go to http://mygitlab.com:8888
or localhost:8888
or 127.0.0.1:8888
