Skip to main content
Hello — this guide walks through setting up a local GitLab instance on a laptop using Oracle VirtualBox and a CentOS virtual machine. The walkthrough covers:
  • Creating a VirtualBox VM template from a CentOS VDI.
  • Configuring a VirtualBox host-only network and using a stable static IP.
  • Cloning the template into a GitLab VM (linked clone recommended).
  • Installing Docker and running GitLab in a container.
  • Accessing the GitLab web UI and initial setup.
The image shows centered blue text that reads "Setup GitLab" with the subtitle "Source Code Repository" on a white background. It looks like a slide title or presentation header.

1 — Download a CentOS VirtualBox image (VDI)

Visit OSBoxes and download a CentOS VirtualBox VDI. Choose 64-bit unless you have a specific need for 32-bit. After downloading, extract the VDI to a folder you will reference when creating the VM. Example metadata (informational only):

2 — Create a VM template in VirtualBox

Create a new VM in VirtualBox and, when prompted for a hard disk, choose “Use existing” and point to the downloaded VDI. Select the appropriate OS type (e.g., “Other Linux (64-bit)” or a CentOS entry) and set memory to 2 GB or more.
A screenshot of Oracle VM VirtualBox Manager. A file dialog is open with "CentOS 7-1708 (64bit).vdi" selected, while the left pane shows a running "minishift" VM and a penguin illustration.

3 — Configure a host-only network for stable static IPs

Using a host-only adapter prevents IPs from changing across reboots and makes it easy to reach VM services locally.
  • In VirtualBox: File → Host Network Manager (or Global Tools → Network → Host-only Networks).
  • Create a new host-only adapter and disable the DHCP server for that adapter.
  • Note the adapter address (typically 192.168.56.1/24) and use a static IP on the VM within that range.
A computer settings window showing network adapter configuration with "Configure Adapter Manually" selected. The IPv4 address is set to 192.168.56.1 with subnet mask 255.255.255.0 and an IPv6 link-local address/prefix displayed.

4 — VM adapter recommendations

For the CentOS template VM:
  • Adapter 1: Bridged — gives the VM internet access through the host.
  • Adapter 2: Host-only — attach the host-only adapter you created and use this for the static IP that you will use to access GitLab.
Power on the template VM, accept any initial prompts, log in with credentials from OSBoxes (often osboxes.org for the default user), then shut it down to keep it as the base template:

5 — Clone the template (create the GitLab VM)

Right-click the template VM and choose Clone → select “Linked clone” to save disk space. Enable “Reset MAC address” so the cloned VM has a unique MAC address (useful when assigning a different static IP).
A screenshot of VirtualBox with a "Clone Virtual Machine" dialog open, showing the "Linked clone" option selected and a "centos-template" VM highlighted in the background. The dialog explains clone types and has "Clone" and "Cancel" buttons at the bottom.
Power on the cloned VM (for example, name it GitLab) and log in. Check network interfaces with ip addr or ifconfig to confirm the host-only interface (for example enp0s8) currently has no IPv4 address.

6 — Configure a static IP inside CentOS

On CentOS 7 (or systems using the legacy network-scripts), network configuration files live in /etc/sysconfig/network-scripts/. You can create an interface config by copying ifcfg-lo and editing it. List and inspect the loopback file:
Example ifcfg-lo (informational):
Copy and edit for your host-only interface (replace enp0s8 and the IP as appropriate):
Example contents for /etc/sysconfig/network-scripts/ifcfg-enp0s8:
Restart networking and verify:
Expected snippet (informational):
Assigning a stable static IP on the host-only adapter makes the VM consistently reachable for SSH and the GitLab web UI. If your environment relies on DHCP, consider reserving an IP in your router or using the host-only approach described here.
Note: On CentOS/RHEL 8+ the system defaults to NetworkManager; use nmcli or nmtui, or install the network-scripts compatibility package if you prefer the classic files.

7 — Prerequisites for Omnibus GitLab (optional)

If you want to install the Omnibus GitLab RPM instead of Docker, install these basic packages and open firewall ports:
These steps prepare the system for a typical CentOS/RHEL GitLab install (mail, SSH, firewall). Docker is the quickest way to get a local GitLab instance running. Install Docker using the official convenience script:
Log out and back in (or reboot) to apply the docker group change if you want to run Docker without sudo. Refer to the official GitLab Docker images and docs for image options and configuration details.
A screenshot of the GitLab Documentation page showing the "Cloud native images" section about Docker images, with links and a comment box below. The header shows the GitLab logo and search bar, and a right-hand "On this page" sidebar.

9 — Run GitLab in Docker

Decide the hostname you will use. For this demo we use the host-only static IP 192.168.56.150 and map the container SSH port to host port 9222 (avoids conflicts with the host SSH on port 22). Create persistent directories and run the Omnibus GitLab CE container:
If your CentOS host has SELinux enabled, add :Z on each volume path to set the correct labels:
Monitor initialization:
Wait until logs indicate the services are up and the container health becomes healthy.

10 — Ports and persistent data (quick reference)

Make sure the host ports chosen do not conflict with services running on the host.

11 — Verify the container and initial login

Check the running container:
Example output (truncated):
When initialization completes, open a browser to the configured external URL:
On first visit you will be prompted to set an initial root password. Set it, then log in with root and the password you created. You will then see the GitLab dashboard.
A screenshot of the GitLab web dashboard showing a "Welcome to GitLab" page with tiles for Create a project, Create a group, Add people, and Configure GitLab. The browser address bar shows a local IP address (192.168.56.150).

12 — What’s next

You now have a local GitLab instance running in a CentOS VM. From here you can:
  • Create projects and groups.
  • Add users and configure access.
  • Push and pull via HTTP or SSH (use host 192.168.56.150:9222 for SSH).
  • Explore backup, restore, and upgrades (see GitLab docs).
If you want a recommended next step, snapshot your VM once GitLab is working so you can quickly restore a known-good state.

Watch Video