GitLab Container Registry
GitLab Container Registry with MinIO Setup Guide
Introduction
This guide provides instructions for integrating GitLab Container Registry with MinIO, an object storage server compatible with Amazon S3 APIs. MinIO can be used to store your container images and artifacts.
Prerequisites
- A running GitLab instance.
- Administrative access to the GitLab server.
- MinIO server installed and running.
- Docker installed on your local machine.
Step 1: Set Up MinIO
Step 1.1: Install MinIO
Follow the instructions on the MinIO Quickstart Guide to install MinIO on your server.
Step 1.2: Start MinIO Server
Run the MinIO server using the following command:
minio server /data
Step 1.3: Configure MinIO Client (mc)
Install the MinIO client and configure it to connect to your MinIO server:
# Download and install MinIO client
wget https://dl.min.io/client/mc/release/linux-amd64/mc
chmod +x mc
sudo mv mc /usr/local/bin/
# Configure the MinIO client
mc alias set myminio http://<minio_server_ip>:9000 <minio_access_key> <minio_secret_key>
Step 2: Enable Container Registry in GitLab
- Log into your GitLab instance.
- Navigate to the Admin Area: Click on the Admin icon (wrench icon) on the sidebar.
- Go to Settings: Select Settings > General.
- Expand the “Container Registry” section: Ensure the Container Registry is enabled.
- Configure the Registry: Set the Registry Host to
registry.gitlab.local
and Registry Port (default is 5000). - Save Changes: Click on the Save changes button at the bottom of the page.
Step 3: Configure GitLab to Use MinIO
Step 3.1: Update gitlab.rb
SSH into your GitLab server and open the gitlab.rb
configuration file:
sudo nano /etc/gitlab/gitlab.rb
Add or update the following lines to configure GitLab to use MinIO for the Container Registry:
registry['enable'] = true
registry['host'] = 'registry.gitlab.local' # Update with your registry hostname
registry['port'] = 5000 # Update with your registry port
# Configure MinIO as the object storage backend
registry['storage'] = {
's3' => {
'accesskey' => '<minio_access_key>',
'secretkey' => '<minio_secret_key>',
'bucket' => 'gitlab-registry',
'region' => 'us-east-1',
'endpoint' => 'http://<minio_server_ip>:9000',
'secure' => false
}
}
Step 3.2: Reconfigure GitLab
After saving changes to the gitlab.rb
file, run the following command to reconfigure GitLab:
sudo gitlab-ctl reconfigure
Step 4: Log in to the GitLab Container Registry
Use Docker to log in to your GitLab Container Registry:
docker login registry.gitlab.local
You will be prompted to enter your GitLab username and personal access token (PAT) or password.
Step 5: Push an Image to the Registry
Step 5.1: Tag Your Docker Image
Tag your Docker image to match the registry format:
docker tag <image_name>:<tag> registry.gitlab.local/<namespace>/<project_name>:<t