Deploying GitLab

[ GitLab  Docker  ]

GitLab is a fantastic tool, whether you are a large enterprise developing many complex projects, or if you are a lonely developer working on the ‘next big thing’. It enables you as a developer to organize and track your projects through their development.

I personally am a huge advocate of self-hosting open-source software, because it allows me to maintain control, and keeps me from having to pay for others to maintain servers. I tend to host the majority of my services through Docker running on a Virtual Machine because it allows me to rapidly startup, shutdown, upgrade, and migrate my services if I need to.

I am going to show you how to host a GitLab instance through Docker.

The official GitLab image for the free version is located at: https://hub.docker.com/r/gitlab/gitlab-ce/

To use this image, you first need to have docker installed, and to do this, you should follow the offical docker installation instructions for your preferred distro. Mine happens to be Fedora, which you can find here https://docs.docker.com/install/linux/docker-ce/fedora/

So, got that? Ok, onto the actual instructions.

sudo docker run -d -p 40443:443 -p 40080:80 -p 40022:22 \
-v /data/gitlab/config:/etc/gitlab \
-v /data/gitlab/logs:/var/log/gitlab \
-v /data/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest

So, what exactly is this command doing?

-d = Run the docker command in the background in detach mode.

-p = Specifies an external port to map to a port in the container (in this case, if you browse to your docker host’s 40443 port, it will display the content hosted on port 443 of your container.

-v = Maps a location on your docker host, to a location in your container. This is how you will make your data persist between containers being shut down.

gitlab/gitlab-ce:latest = This is the docker image that you are telling it to run. This defaults to use https://hub.docker.com/r/{image}:{image_version}

Give your new GitLab instance a few minutes to come online, then browse to localhost:40080, and view your new self-hosted SCM. At this point, you just need to create a username and password, and start using it! Share your service with your friends if you can afford to, because not everyone has spare hardware laying around to try the same.

Written on February 22, 2018