Prerequisites
- VPS Server: You need access to a VPS server, either self-managed or from a hosting provider.
- Docker and Docker Compose: Ensure Docker and Docker Compose are installed on your server.
Prepare the Docker Compose File
Create a docker-compose.yml file for GitLab. This file defines the GitLab service, configurations, and volumes.
|
|
Replace your-vps-ip with your VPS server’s IP address.
Create Necessary Directories
|
|
Start GitLab Docker Container
|
|
This command downloads the GitLab Docker image (if not already downloaded) and starts the GitLab service in detached mode. Please note that GitLab will take some time to initialize, around 15 minutes.
Configure GitLab
After starting the container, you can access GitLab via http://your-vps-ip:40150
.
Getting root password
Run the following command to list all running containers and find the GitLab container ID:
|
|
Located to the Gitlab container ID
Using the GitLab container ID, run the following command to get the root password:
|
|
After getting the password, go back to the GitLab login page and sign in with username “root”.
Additional Configuration (Optional)
-
Custom Domain: If you have a domain, configure DNS settings to point to your VPS IP address. Update the external_url in the docker-compose.yml file to match your domain, e.g., https://gitlab.example.com.
-
HTTPS (SSL/TLS) Setup: For securing your GitLab instance with HTTPS, it’s recommended to use a reverse proxy like Nginx or set up a Let’s Encrypt certificate. Refer to the previous response on how to set up HTTPS with Nginx and Let’s Encrypt.
Additional Notes:
- Ensure your VPS firewall allows traffic the ports that you are using in the docker-compose file.
- Regularly update GitLab and Docker to maintain security.
- Always keep your server and GitLab instance up to date with the latest security patches.
By following these steps, you’ll have GitLab up and running on your VPS server using Docker. Remember, security, backup, and maintenance are critical aspects of managing any server-based application.