# Host Your Own GitHub Alternative with GitLab Docker Container

## What is GitLab

> GitLab is an open source end-to-end software development platform with built-in version control, issue tracking, code review, CI/CD, and more. Self-host GitLab on your own servers, in a container, or on a cloud provider. -https://gitlab.com/gitlab-org/gitlab

## Installing Docker

1. Log into the Linux based device
2. Run the following commands in the terminal
   # install prerequisites
   sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg-agent -y
   # add docker gpg key
   curl -fsSL https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release)/gpg | sudo apt-key add -
   # add docker software repository
   sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release) $(lsb_release -cs) stable"
   # install docker
   sudo apt install docker-ce docker-compose containerd.io -y
   # enable and start docker service
   sudo systemctl enable docker && sudo systemctl start docker
   # add the current user to the docker group
   sudo usermod -aG docker $USER
   # reauthenticate for the new group membership to take effect
   su - $USER

## Running GitLab

1. Now that Docker is installed, run the following commands to setup the GitLab Docker container and run it
   # create working directory
   sudo mkdir /home/$USER/docker/gitlab -p
   # run the GitLab docker container
   docker run --name gitlab -d --hostname DNSofHost -p 8000:80 -v /home/$USER/docker/gitlab/config:/etc/gitlab -v /home/$USER/docker/gitlab/logs:/var/log/gitlab -v /home/$USER/docker/gitlab/data:/var/opt/gitlab --restart=unless-stopped gitlab/gitlab-ce:latest
   # output root user password
   docker exec -it gitlab cat /etc/gitlab/initial_root_password
2. Copy the password to your clipboard
3. Open a web browser and navigate to http://DNSorIP:8000
4. Login with the username root and the password copied earlier
5. Welcome to GitLab running in a Docker container

Documentation: https://hub.docker.com/r/gitlab/gitlab-ce/