As always: before you do such an update, make sure to create a backup of all your files. If something goes wrong, this may lead to data loss!
To update an existing Docker container manually, the following steps are necessary;
Go to Registry and download new image (mostly the “latest” version)
Go to Container, select the container you need to update and stop it
From Actions menu select “Clear” Edit: Under DSM7, the “Clear” command has been renamed “Reset”.
Start the container again
This will clear the complete container and start with the newly downloaded Docker image. Since the data folders are mounted into the container, this will not erase the apllications data. Configurations are also not affected by this.
Side note: when updating a major version of gitlab/gitlab-ce, make sure to follow the update paths! This requires updates in smaller steps (minor versions).
Automatically update Docker images
Updating a Docker image manually might be fine for a small number of images. But there is a more elegant way by using another Docker container called Watchtower. This one can update Docker containers automatically. The image is called containrrr/watchtower. A simple setup can be performed with the following steps:
Load image containrrr/watchtower in the Docker registry
This will start the Watchtower image and update all container once. The container created for this runs once and can then be found switched off in the list of containers. Now you can start it manually again and again as needed or let it run at certain times via Synology Task Scheduler. The command for the task scheduler is then as follows:
docker start watchtower-once -a
Let Watchtower run permanently
Alternatively you can use the scheduler in Watchtower itself. If you want to start it every Monday at 4 a.m., then enter the following command on the shell:
It is important to set the time zone to your because otherwise you will have an offset to UTC. In addition, the container is not terminated but always restarted. Even if it crashed or the NAS was restarted. The last parameter uses the cron syntax for scheduling the task.
The settings above are necessary, if port routing is set like the following:
Using DSM package manager installation
This installation of GitLab on Synology uses localhost as a default value for external url. This may lead to some problems when accessing GitLab over another IP or host name. In my case, this lead to missing icons and a non functional WebIDE. An inspection of the html page shows, that some resources are requested over http://localhost/... which leads to 404 errors for those resources.
Since the GitLab container on Synology is not based on the omnibus package, you can not use directly external_url in /etc/gitlab/gitlab.rb. If you want to change the url you can do it by changing the docker environment parameter GITLAB_HOST.
The setup described in this post has been tested on the following system:
DS216+II with 8GB RAM
DSM 6.2.3-25426 Update 2
In addition, the following software packages have already been installed on the system using the Synology package manager:
GitLab is installed via the Docker Registry:
gitlab/gitlab-ce:latest (in my case GitLab 13.5.1-ce.0)
You can skip this part, if GitLab is already running on your Synology and continue with the step Install GitLab Runner.
To install GitLab, open the Docker Registry and search for “gitlab”. Double click the entry gitlab/gitlab-ce:latest and select the latest version:
After the image is loaded, it will be listed under image. Launch this image and set the folders to be mounted as shown in the following image. This will simplify the access to the docker files within your Synology.
The port settings depend on your system. Normally, HTTP is accessible at port 80 or HTTPS on port 443. If your system already uses other apps that are running on those port, you can adjust them in Port Settings.
After completing the setup, it might take some time until the GitLab web surface is available. When accessing GitLab for the first time, you can specify a password for the root environment. The default username for the admin area is root. Now you can create user accounts, projects and perform any adjustments that fit your needs.
Install GitLab Runner
As the Synology DSM uses Docker to run GitLab, we can use Docker as well to install GitLab Runner. For this, connect to the Synology using SSH:
ssh <admin-user>@<synology> -p <port>
Now we can install the Gitlab Runner Docker container that can run other Docker containers to perform the runner tasks:
Runtime platform arch=amd64 os=linux pid=16 revision=e95f89a0 version=13.4.1
Running in system-mode.
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
Please enter the gitlab-ci token for this runner:
Please enter the gitlab-ci description for this runner:
Please enter the gitlab-ci tags for this runner (comma separated):
Registering runner... succeeded runner=sA4DKorC
Please enter the executor: docker-ssh, parallels, docker+machine, kubernetes, docker, shell, ssh, virtualbox, docker-ssh+machine, custom:
Please enter the default Docker image (e.g. ruby:2.6):
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
In this case, the executor docker and the base image alpine:latest is used for this container.
If you use a self-signed certificate for GItLab, then you have to specify the certificate with the option --tls-ca-file during registration:
Let’s connect to the bash terminal of this container to change some settings:
docker exec -it gitlab_runner_docker /bin/bash
The created Docker container is an alpine base system without any packages installed. To perform the changes, we need a simple terminal text editor like nano or vim. The following commands will install nano for this task:
apt-get install nano
Now you can use nano to edit the GitLab Runner config file:
And add the following lines as highlighted in the config file below:
That’s it. Now you can use this GitLab Runner for your repositories and run jobs by using other Docker containers.
Example usage in .gitlab-ci.yml
The following example uses a php container to run tests for a simple PHP application and deploy the code to a server. Some of the settings depend on the setup of your PHP application, so the example will not work out of the box. But it can give you a good idea of what is possible.
# Configure mysql environment variables (https://hub.docker.com/_/mysql/)
# Initialize database, etc
- composer install
- composer phpunit
# run on server 'git checkout master && git pull origin master && exit'