In this lab, we will get our hands dirty with a versatile method for GitLab installation that transcends OS dependencies. Explore how we leverage the power of Docker Engine in the below lab to achieve this streamlined and efficient setup.
The prerequisites will be the same. check previous Gitlab installation post
create a directory and start the docker service
root@TzoneLabs:~# mkdir -p /data/gitlab/ssl
root@TzoneLabs:~# systemctl start docker.service ## docker should install on server
put your domain certificate and key
root@TzoneLabs:~# cd /data/gitlab/ssl
root@TzoneLabs:/data/gitlab/ssl# ls
my_domain.crt my_domain.key
root@TzoneLabs:/data/gitlab/ssl#
Install GitLab using Docker Engine
Run the below command to create and start the container.
docker run --dt \
-h gitlab.tzonelabs.com \
-p 443:443 -p 80:80 -p 22:22 \
--name gitlab \
--restart always \
-v /data/gitlab/config:/etc/gitlab:Z \
-v /data/gitlab/logs:/var/log/gitlab:Z \
-v /data/gitlab/data:/var/opt/gitlab:Z \
--shm-size 256m \
--env GITLAB_OMNIBUS_CONFIG="external_url 'https://gitlab.tzonelabs.com/';" \
--env nginx['ssl_certificate']="/data/gitlab/ssl/domain.crt" \
--env nginx['ssl_certificate_key']="/data/gitlab/ssl/domain.key" \
gitlab/gitlab-ce:latest
same command in one line–
root@TzoneLabs:~# docker run -d -h gitlab.tzonelabs.com -p 443:443 -p 80:80 -p 22:22 --name gitlab --restart always -v /data/gitlab/config:/etc/gitlab:Z -v /data/gitlab/logs:/var/log/gitlab:Z -v /data/gitlab/data:/var/opt/gitlab:Z --shm-size 256m --env GITLAB_OMNIBUS_CONFIG="external_url 'https://gitlab.tzonelabs.com/';" --env nginx['ssl_certificate']="/data/gitlab/ssl/domain.crt" --env nginx['ssl_certificate_key']="/data/gitlab/ssl/domain.key" gitlab/gitlab-ce:latest
once your container run your GitLab config file will be on the below location
root@TzoneLabs:~# cd /data/gitlab/config
root@TzoneLabs:~# vim gitlab.rb
if you have changed any parameter in gitlab.rb file then you have to reconfigure GitLab using the below command to new changes take place.
Cross-check changes inside containers and run the below commands.
root@TzoneLabs:~# docker exec -it gitlab bash
gitlab-ctl reconfigure ## inside the gitlab container
How to back up your GitLab and restore.
if your GitLab is running on the server without a docker
create backup
root@TzoneLabs:~# gitlab-backup create
## Note -- the Default path of gitlab backup is /var/opt/gitlab/backups/
restore backup
## Note -- copy backup to directory /var/opt/gitlab/backups
root@TzoneLabs:~# gitlab-backup restore
if your GitLab is running on the docker
create backup
root@TzoneLabs:~# docker exec -t <container name> gitlab-backup create
## Note -- the Default path of gitlab backup is /var/opt/gitlab/backups/
restore backup
## Note -- copy backup to directory /var/opt/gitlab/backups
root@TzoneLabs:~# docker exec -t <container name> gitlab-backup restore
also Read:-
GitLab installation on Ubuntu 22.04
GitLab’s Implementation of Group-Based Authorization
Reference:- https://about.gitlab.com/install/