Arch Linux - Docker Node - Updating GitLab Container - ( Part V )

I have revisited my GitLab container recently and noticed that it is asking for an update. Updating a GitLab docker container is relatively easy.

Let's follow GitLab's instructions.

1) Take a Backup

Let's get the GitLab container name.

CONTAINER ID   IMAGE                     COMMAND             CREATED        STATUS                  PORTS     NAMES
xxxxxxxxxxx   gitlab/gitlab-ee:latest   "/assets/wrapper"   3 months ago   Up 27 hours (healthy)             gitlab

To backup we need to execute the following command :

docker exec -t gitlab gitlab-backup create
Warning: Your gitlab.rb and gitlab-secrets.json files contain sensitive data 
and are not included in this backup. You will need these files to restore a backup.
Please back them up manually.
Backup task is done.

I do not need to worry about the configuration backups because my installation creates a backup daily and I will use the backups to restore.

You should check the current version and follow the upgrade path if upgrading between major versions.

Docker images can use the below to check the current version.

sudo cat /gitlab-data-folder/gitlab/data/gitlab-rails/VERSION

2) Container Update

Before downloading the latest image we need to set the environment variable $GITLAB_HOME pointing to our installation home folder.

export GITLAB_HOME=/root/docker-projects/vlan.65-gitlab
/root/docker-projects/vlan.65-gitlab

Let's download the latest image.

docker-compose pull
/root/docker-projects/vlan.65-gitlab
Make sure that the version is set to latest in your docker-compose.yml file.
Pulling gitlab ... done

We will stop the outdated container.

docker container stop gitlab
/root/docker-projects/vlan.65-gitlab

And finally update it but do not start yet.

docker-compose up --no-start
/root/docker-projects/vlan.65-gitlab

3) Restore Config Backup

If you are not mapping local folders to the container, when the container is recreated the configuration files will be recreated as well. Otherwise, skip to the next step.

Restore the whole configuration backed up folder.

-rw------- 1 root root 123K Sep 26 23:42 gitlab.rb
-rw------- 1 root root  19K Jan  7 17:56 gitlab-secrets.json
-rw------- 1 root root  513 Sep 26 14:00 ssh_host_ecdsa_key
-rw-r--r-- 1 root root  180 Sep 26 14:00 ssh_host_ecdsa_key.pub
-rw------- 1 root root  411 Sep 26 14:00 ssh_host_ed25519_key
-rw-r--r-- 1 root root  100 Sep 26 14:00 ssh_host_ed25519_key.pub
-rw------- 1 root root 2.6K Sep 26 14:00 ssh_host_rsa_key
-rw-r--r-- 1 root root  572 Sep 26 14:00 ssh_host_rsa_key.pub
drwxr-xr-x 2 root root 4.0K Sep 26 21:23 ssl
drwxr-xr-x 2 root root 4.0K Sep 26 20:12 trusted-certs
Files to restore from backup.

4) Start the Container

Let's start our updated container.

docker container start gitlab