Run GitLab on QNAP NAS With Container

GitLab is a web-based Git repository manager with Git repository management, code reviews, issue tracking, wikis. It is very similar to GitHub but can be hosted on your own server. It will be awesome to have an on-premise git server for my private projects and personal documents. I can also use it to mirror remote repositories hosted on GitHub. Recently I bought a QNAP 451 NAS. It has a feature called Container Station, which integrates Linux Containers (LXC) and Docker virtualisation technologies. Container Station allows me to operate multiple isolated Linux® systems on a QNAP NAS. This makes this NAS a perfect host for my git server.

Create a GitLab container

First you need to have Container Station Installed. Here you can find detailed instructions on how to do that.

App Store

Then open Container Station, click Create Container, choose GitLib which happens to be the first one in the list.

App Store

App Store

Docker images are pulled from the popular docker registry Dockerhub. It is interesting to see that QNAP Container Station knows to launch the GitLib image with docker-compose. Which results in creating three containers. These three containers provide a complete GitLab service.

gitlab1_gitlab_1
gitlab1_postgresql_1
gitlab1_redis_1

Each container can be individually configured from UI.

App Store

Open a web browser and go to http://10.0.1.25:10080/, log in(default username / password: root / 5iveL! Fe) to start using GitLab.

App Store

I want to checkout out what is running under the hood. Open a terminal and SSH into the NAS, list all the running containers.

ssh root@10.0.1.25

[~] # docker ps
CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS              PORTS                                                   NAMES
e0805483da90        sameersbn/gitlab:8.2.3        "/sbin/entrypoint.sh "   21 hours ago        Up 21 hours         443/tcp, 0.0.0.0:10022->22/tcp, 0.0.0.0:10080->80/tcp   gitlab1_gitlab_1
13491bc0d510        sameersbn/postgresql:9.4-11   "/sbin/entrypoint.sh"    21 hours ago        Up 21 hours         5432/tcp                                                gitlab1_postgresql_1
25217f65f54a        sameersbn/redis:latest        "/sbin/entrypoint.sh"    21 hours ago        Up 21 hours         6379/tcp                                                gitlab1_redis_1

Note except gitlab1_gitlab_1, other two don’t have ports map to the host. How does the gitlab1_gitlab_1 connect to them?
Lets take a close look at inspect gitlab1_gitlab_1

docker inspect gitlab1_gitlab_1

...
    "Links": [
        "/gitlab1_postgresql_1:/gitlab1_gitlab_1/postgresql",
        "/gitlab1_postgresql_1:/gitlab1_gitlab_1/postgresql_1",
        "/gitlab1_redis_1:/gitlab1_gitlab_1/redis_1",
        "/gitlab1_redis_1:/gitlab1_gitlab_1/redisio",
        "/gitlab1_postgresql_1:/gitlab1_gitlab_1/gitlab1_postgresql_1",
        "/gitlab1_redis_1:/gitlab1_gitlab_1/gitlab1_redis_1"
    ],
...

Aha, here we go. Instead of network port mappings, it uses linking system to connect to postgressql and redis services. Very neat!

Network port mappings are not the only way Docker containers can connect to one another. Docker also has a linking system that allows you to link multiple containers together and send connection information from one to another. When containers are linked, information about a source container can be sent to a recipient container. This allows the recipient to see selected data describing aspects of the source container

Summary

Thanks for Container Station, setting up a GitLab server on QNAP NAS is a straight forward and joyful job. QNAP does an excellent job in integrating Docker virtualization with its QTS operating system. If you need more control, you still have full access to the Docker engine which QNAP Container Station built on top.