> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# APPENDIX A Demo Gitlab Setup

> Guide to set up local GitLab on CentOS with VirtualBox and Docker, covering VM template, host only network static IP, Docker install, running Omnibus container and initial login

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.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/1i2YcqiBKQjc0R77/images/OpenShift-3-for-the-Absolute-Beginners/Conclusion-and-APPENDIX/APPENDIX-A-Demo-Gitlab-Setup/setup-gitlab-source-code-repository.jpg?fit=max&auto=format&n=1i2YcqiBKQjc0R77&q=85&s=c5af42d4da29b178b8b34bab16daad66" alt="The image shows centered blue text that reads &#x22;Setup GitLab&#x22; with the subtitle &#x22;Source Code Repository&#x22; on a white background. It looks like a slide title or presentation header." width="1920" height="1080" data-path="images/OpenShift-3-for-the-Absolute-Beginners/Conclusion-and-APPENDIX/APPENDIX-A-Demo-Gitlab-Setup/setup-gitlab-source-code-repository.jpg" />
</Frame>

## 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):

```bash theme={null}
# Example download details (informational)
VirtualBox (VDI) 32bit  Download  Size: 939MB
SHA256: 7422e6ba4a9e876d8bcb97094596e60e337c04d7da4aa573d485e1765e18

VirtualBox (VDI) 64bit  Download  Size: 938MB
SHA256: e38e0bf85d3b4456a275a08b554669915b163598aa4eab49af00fc9f5958

VirtualBox (VDI) x86_64  Download  Size: 963.5MB
SHA256: 9B14630969A7926ADD6B871848744E20C8BBBA59041085BCC425B0BE5F0A1
```

## 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.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/1i2YcqiBKQjc0R77/images/OpenShift-3-for-the-Absolute-Beginners/Conclusion-and-APPENDIX/APPENDIX-A-Demo-Gitlab-Setup/virtualbox-minishift-centos7-vdi-penguin.jpg?fit=max&auto=format&n=1i2YcqiBKQjc0R77&q=85&s=a7e7e7b5d8b2e6468f39e17745dead50" alt="A screenshot of Oracle VM VirtualBox Manager. A file dialog is open with &#x22;CentOS 7-1708 (64bit).vdi&#x22; selected, while the left pane shows a running &#x22;minishift&#x22; VM and a penguin illustration." width="1920" height="1080" data-path="images/OpenShift-3-for-the-Absolute-Beginners/Conclusion-and-APPENDIX/APPENDIX-A-Demo-Gitlab-Setup/virtualbox-minishift-centos7-vdi-penguin.jpg" />
</Frame>

## 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.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/1i2YcqiBKQjc0R77/images/OpenShift-3-for-the-Absolute-Beginners/Conclusion-and-APPENDIX/APPENDIX-A-Demo-Gitlab-Setup/manual-adapter-192-168-56-1.jpg?fit=max&auto=format&n=1i2YcqiBKQjc0R77&q=85&s=b0383ea7f0d1ecb2dbdf7251c573b5ad" alt="A computer settings window showing network adapter configuration with &#x22;Configure Adapter Manually&#x22; 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." width="1920" height="1080" data-path="images/OpenShift-3-for-the-Absolute-Beginners/Conclusion-and-APPENDIX/APPENDIX-A-Demo-Gitlab-Setup/manual-adapter-192-168-56-1.jpg" />
</Frame>

## 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:

```bash theme={null}
sudo shutdown now
```

## 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).

<Frame>
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/kodekloud-c4ac6d9a/images/OpenShift-3-for-the-Absolute-Beginners/Conclusion-and-APPENDIX/APPENDIX-A-Demo-Gitlab-Setup/virtualbox-linked-clone-dialog-centos_template.jpg" alt="A screenshot of VirtualBox with a &#x22;Clone Virtual Machine&#x22; dialog open, showing the &#x22;Linked clone&#x22; option selected and a &#x22;centos-template&#x22; VM highlighted in the background. The dialog explains clone types and has &#x22;Clone&#x22; and &#x22;Cancel&#x22; buttons at the bottom." />
</Frame>

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:

```bash theme={null}
ls /etc/sysconfig/network-scripts/
cat /etc/sysconfig/network-scripts/ifcfg-lo
```

Example `ifcfg-lo` (informational):

```bash theme={null}
DEVICE=lo
IPADDR=127.0.0.1
NETMASK=255.0.0.0
NETWORK=127.0.0.0
BROADCAST=127.255.255.255
ONBOOT=yes
NAME=loopback
```

Copy and edit for your host-only interface (replace `enp0s8` and the IP as appropriate):

```bash theme={null}
sudo cp /etc/sysconfig/network-scripts/ifcfg-lo /etc/sysconfig/network-scripts/ifcfg-enp0s8
sudo vi /etc/sysconfig/network-scripts/ifcfg-enp0s8
```

Example contents for `/etc/sysconfig/network-scripts/ifcfg-enp0s8`:

```bash theme={null}
DEVICE=enp0s8
BOOTPROTO=none
IPADDR=192.168.56.150
NETMASK=255.255.255.0
NETWORK=192.168.56.0
BROADCAST=192.168.56.255
ONBOOT=yes
NAME=enp0s8
```

Restart networking and verify:

```bash theme={null}
sudo systemctl restart network
ifconfig enp0s8
```

Expected snippet (informational):

```bash theme={null}
enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.56.150  netmask 255.255.255.0  broadcast 192.168.56.255
        inet6 fe80::a00:27ff:fe91:625  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:91:06:25  txqueuelen 1000  (Ethernet)
```

<Callout icon="lightbulb" color="#1CB2FE">
  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.
</Callout>

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:

```bash theme={null}
sudo yum install -y curl policycoreutils-python openssh-server
sudo systemctl enable --now sshd
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --reload

sudo yum install -y postfix
sudo systemctl enable --now postfix
```

These steps prepare the system for a typical CentOS/RHEL GitLab install (mail, SSH, firewall).

## 8 — Install Docker (recommended for quick local GitLab)

Docker is the quickest way to get a local GitLab instance running. Install Docker using the official convenience script:

```bash theme={null}
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo systemctl enable --now docker
sudo usermod -aG docker $USER
```

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.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/1i2YcqiBKQjc0R77/images/OpenShift-3-for-the-Absolute-Beginners/Conclusion-and-APPENDIX/APPENDIX-A-Demo-Gitlab-Setup/gitlab-documentation-cloud-native-images-screenshot.jpg?fit=max&auto=format&n=1i2YcqiBKQjc0R77&q=85&s=5993d82561e70398ed2cb6b3e55cddc9" alt="A screenshot of the GitLab Documentation page showing the &#x22;Cloud native images&#x22; section about Docker images, with links and a comment box below. The header shows the GitLab logo and search bar, and a right-hand &#x22;On this page&#x22; sidebar." width="1920" height="1080" data-path="images/OpenShift-3-for-the-Absolute-Beginners/Conclusion-and-APPENDIX/APPENDIX-A-Demo-Gitlab-Setup/gitlab-documentation-cloud-native-images-screenshot.jpg" />
</Frame>

## 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:

```bash theme={null}
sudo mkdir -p /srv/gitlab/config /srv/gitlab/logs /srv/gitlab/data

sudo docker run --detach \
  --hostname 192.168.56.150 \
  -e GITLAB_OMNIBUS_CONFIG="external_url 'http://192.168.56.150'; gitlab_rails['gitlab_shell_ssh_port'] = 9222" \
  --publish 443:443 --publish 80:80 --publish 9222: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 \
  gitlab/gitlab-ce:latest
```

If your CentOS host has SELinux enabled, add `:Z` on each volume path to set the correct labels:

```bash theme={null}
sudo docker run --detach \
  --hostname 192.168.56.150 \
  -e GITLAB_OMNIBUS_CONFIG="external_url 'http://192.168.56.150'; gitlab_rails['gitlab_shell_ssh_port'] = 9222" \
  --publish 443:443 --publish 80:80 --publish 9222:22 \
  --name gitlab \
  --restart always \
  --volume /srv/gitlab/config:/etc/gitlab:Z \
  --volume /srv/gitlab/logs:/var/log/gitlab:Z \
  --volume /srv/gitlab/data:/var/opt/gitlab:Z \
  gitlab/gitlab-ce:latest
```

Monitor initialization:

```bash theme={null}
sudo docker logs -f gitlab
```

Wait until logs indicate the services are up and the container health becomes healthy.

## 10 — Ports and persistent data (quick reference)

| Purpose | Host | Container |
| - | -: | - |
| HTTP | `80` | `80` |
| HTTPS | `443` | `443` |
| SSH (Git over SSH) | `9222` (host) | `22` (container) |
| Configuration | `/srv/gitlab/config` | `/etc/gitlab` |
| Logs | `/srv/gitlab/logs` | `/var/log/gitlab` |
| Data | `/srv/gitlab/data` | `/var/opt/gitlab` |

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:

```bash theme={null}
sudo docker ps
```

Example output (truncated):

```text theme={null}
CONTAINER ID   IMAGE                      COMMAND         CREATED         STATUS         PORTS                                      NAMES
e52b77c8d577   gitlab/gitlab-ce:latest    "/assets/wrapper"  2 minutes ago   Up 1m (health: starting)  0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:9222->22/tcp  gitlab
```

When initialization completes, open a browser to the configured external URL:

```text theme={null}
http://192.168.56.150
```

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.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/1i2YcqiBKQjc0R77/images/OpenShift-3-for-the-Absolute-Beginners/Conclusion-and-APPENDIX/APPENDIX-A-Demo-Gitlab-Setup/gitlab-welcome-192-168-56-150.jpg?fit=max&auto=format&n=1i2YcqiBKQjc0R77&q=85&s=9623eefff21c2acf986b486d27c25bd9" alt="A screenshot of the GitLab web dashboard showing a &#x22;Welcome to GitLab&#x22; 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)." width="1920" height="1080" data-path="images/OpenShift-3-for-the-Absolute-Beginners/Conclusion-and-APPENDIX/APPENDIX-A-Demo-Gitlab-Setup/gitlab-welcome-192-168-56-150.jpg" />
</Frame>

## 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).

## Links and references

* VirtualBox: [https://www.virtualbox.org](https://www.virtualbox.org)
* OSBoxes (CentOS VDI downloads): [https://www.osboxes.org](https://www.osboxes.org)
* GitLab Docker images & documentation: [https://docs.gitlab.com/omnibus/docker/](https://docs.gitlab.com/omnibus/docker/)
* Docker install script: [https://get.docker.com](https://get.docker.com)

If you want a recommended next step, snapshot your VM once GitLab is working so you can quickly restore a known-good state.

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/openshift-3-for-the-absolute-beginners/module/459c09b9-e158-467d-804e-ec708a55d72f/lesson/59bebc11-56ce-4ed0-962c-64382a904473" />
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.