How to Install Gitlab on Ubuntu 18.04 Bionic Beaver


Install a Gitlab server on Ubuntu 18.04


Ubuntu 18.04 Bionic Beaver


A running install of Ubuntu 18.04 with root privileges


  • # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
  • $ – requires given linux commands to be executed as a regular non-privileged user


Gitlab is the solution for hosting your own Git repositories. Not only are the server systems on par with commercial options like Bitbucket and Github, it’s got an amazing web interface that’s intuitive and simple for just about any user.


There are two main options for installing a Gitlab server. Both are fairly convenient, and which you choose is largely dependent on how you want to run your server. You can either spin up a Docker container, which is better for servers running other services. Alternatively, you can run Gitlab directly on Ubuntu. It sort of takes over a lot of ports, so this method is best for dedicated servers.


If you don’t already have Docker installed on your system, check out our guide to get up to speed. Once you do have Docker ready, you can install the official Docker image for Gitlab CE.

Below is the startup command suggested by the Gitlab developers.

$ sudo docker run --detach \
    --hostname \
    --publish 443:443 --publish 80:80 --publish 22:22 \
    --name gitlab \
    --restart always \
    --volume /srv/gitlab/config:/etc/gitlab \
    --volume /srv/gitlab/logs:/var/log/gitlab \
    --volume /srv/gitlab/data:/var/opt/gitlab \

You should, however, tweak that command to suit your needs. Change the storage locations to fit your needs. Don’t forget to change the hostname and ports to match your server configuration too. Gitlab requires HTTP, HTTPS, and SSH ports.

The good news is, that’s actually all you need to do to get Gitlab running on Docker. It will automatically restart itself when your restart your server too.


If you’d rather run Gitlab directly on your server, Gitlab has you covered there too.

Start off by installing the required dependencies.

$ sudo apt install curl openssh-server ca-certificates postfix

Gitlab comes from its own repository. The Gitlab developers wrote a convenient install script for Ubuntu and Debian systems to make the setup simple. Grab the script and run it.

$ curl -sS | sudo bash

After the script is done, you can install the Gitlab CE package.

$ sudo apt install gitlab-ce

Once you have the package installed, you can run the provided configuration utility. It provides an automatic configuration. You can modify things later, if you need to.

$ sudo gitlab-ctl reconfigure

When the configuration is done, your server will be ready to use.

Using Gitlab

You can access your Gitlab server either via localhost or the hostname that you specified in your Docker setup.

Ubuntu Bionic Gitlab First Run

You’ll immediately be prompted to provide a password for the administrative account. The username of that account is root by default, but you can change it. Still, it’s better to create a regular use account for regular use.

Ubuntu Bionic Gitlab Welcome Screen

After you create your account, you’ll be greeted with Gitlab’s “Welcome” screen. From there, you’ll be able to access the entire Gitlab dashboard. It’s through that dashboard that you can create both new users and projects.

SSH Keys

Like with other web-based Git repositories, using SSH keys to connect securely to your repository is usually the best idea. If you already have an SSH key, you can absolutely use that. If not, you can make one easily enough.

$ ssh-keygen -r rsa -C "user@domain"

The user@domain section could either be your email address or your username and the hostname of your computer. Either is fine.

After you have your key, cat it out into your terminal.

$ cat ~/.ssh/

Ubuntu Bionic Gitlab SSH Keys

Back in the Gitlab interface, pull down the user menu by clocking on the icon in the top right corner. Click on “Settings.” On the resulting window, click on “SSH Keys” in the left side menu. Copy the key from the terminal. Get the line that begins with ssh-rsa. Paste it in the box marked “Key” in Gitlab. Give it a name, and save it.

Closing Thoughts

There’s a lot that you can do with Gitlab, but you’re set up and ready to run your own repository. Gitlab handles almost everything for you. Gitlab is also great for team projects, so you can easily set up accounts for your teammates and get started collaborating like you would on any other platform, only you are in complete control.