So! I have a QNAP NAS and I finally decided that I should use it to set up a private development environment and finally get around to creating some of the MANY side projects I have rolling around in my head.
The cool thing about my QNAP is I can install QNAP’s Container Station which gives me Docker. I’m not the biggest fan of Container Station but it’s not horrible for container management in non-mission critical situations – like my new private development environment. I found a few ways to back up my instance to ensure that I don’t lose anything valuable. I might do a separate post about that later.
Through Container Station, I set up GitLab with a few clicks and was pretty much off to the races. By turning on Port Forwarding in my router, I was able connect to it outside of my LAN and push code to my instance.
Now that I got Gitlab up and running, why not try and get CI/CD working?
I decided to see if I can get the Gitlab Runner up and running through Container Station so I could take advantage of Gitlab’s CI/CD. I installed the image and get it up and running. I also went through the GitLab Runner docs to configure it so my GitLab instance could see/use it.
All was well! … Then this happened when I submit a job to kick off the pipeline…
Preparation failed: Cannot connect to the Docker daemon at unix:///var/run/docker.sock
All the documentation and forums out there explain pretty quickly what the root cause of this is and how to fix it. However, all those venues assume you’re running Docker through the command line. Container Station has a few flaws. One of the major ones is that you can’t edit a lot about your containers once they’re created.
The fix for this problem is simple. Mount the host server (my QNAP) /var/run/docker.sock file to the gitlab-runner container. In Container Station, you can’t add shared folders (mounts) after container creation. So, I had to delete my container and create a new one to see if I can mount it during creation. Then, I encountered another hurdle. The Container Station UI only let’s you mount folders that you can navigate to in their UI. Luckily, this is a pretty easy hurdle to get over.
Here’s how I got it to work!
I ssh’d into my QNAP and went to directory that I knew I could navigate to in the UI and made a symbolic link to my QNAP’s /var/run folder. Then in the UI, I selected my linked folder. I set up the Gitlab Runner once again like I had it before. BOOM! Everything worked!
I know this isn’t the most amazing solution or an amazing problem even to begin with but I was surprised at the lack of information on Container Station out there in the interwebs. That’s why I decided to write this up so that if others out there are bored and decide they want to set up their own GitLab instance using Container Station and want to do CI, they can use this hack as well.