Dec 10, 2022 2 min read

Gitlab Self Hosted Container Repository

Gitlab Self Hosted Container Repository

In this article, we will provide a step-by-step guide on how to create a container repository in GitLab Omnibus installation. We will also explain how to enable HTTPS access to your repository and how to use the GitLab web interface to manage your images. Container repositories are useful for storing and managing your Docker images in a centralized location, allowing you to share and collaborate on your containerized applications. Follow along to learn how to set up a container repository in GitLab.

To create a container repository in GitLab Omnibus installation, follow these steps:

  1. Log in to your GitLab server and go to the "Packages & Registries" page in the admin area.
  2. Click the "Containers" tab and then click the "New container repository" button.
  3. Enter a name for your repository and select a visibility level. Private repositories are only visible to authorized users, while public repositories are visible to everyone.
  4. Click the "Create repository" button to create your repository.
  5. Once the repository is created, you can push your Docker images to it. To push an image to your repository, first log in to your GitLab server using the docker login command. You will need to provide your GitLab username and password.
  6. Once you are logged in, you can push your Docker image to your GitLab container repository using the docker push command. The following example shows how to push an image named my-image to a repository named my-repository:
docker push my-repository/my-image

7. You can also use the GitLab web interface to manage your container repository. From the "Packages & Registries" page, you can view the images in your repository, delete images, and set access control for your repository.

With these steps, you can create and manage a container repository in GitLab Omnibus installation. This allows you to store and manage your Docker images in a centralized location, making it easier to share and collaborate on your containerized applications.

To enable HTTPS access to your container repository in GitLab Omnibus installation, you will need to edit the gitlab.rb configuration file. This file is located in the /etc/gitlab directory on your GitLab server.

To edit the gitlab.rb file, follow these steps:

  • Log in to your GitLab server using a terminal or SSH connection.
  • Use a text editor to open the gitlab.rb file. For example, you can use the nano editor by running the following command:
sudo nano /etc/gitlab/gitlab.rb
  • Find the section of the file that configures the registry settings. It should look similar to this:
registry_external_url 'https://registry.example.com'
registry_nginx['ssl_certificate'] = "/etc/gitlab/ssl/example.crt"
registry_nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/example.key"
  • Update the registry_external_url setting with the URL of your GitLab server and the path to the registry. For example, if your GitLab server is accessible at https://gitlab.example.com, you would set the registry_external_url to https://gitlab.example.com/registry.
  • Update the registry_nginx['ssl_certificate'] and registry_nginx['ssl_certificate_key'] settings with the paths to your SSL certificate and private key files. These files should be located in the /etc/gitlab/ssl directory.
  • Save the gitlab.rb file and exit the text editor.
  • Run the gitlab-ctl reconfigure command to apply the changes to your GitLab configuration. This will update the nginx configuration and restart the GitLab services.

With these steps, you have enabled HTTPS access to your container repository in GitLab Omnibus installation. You can now access your repository securely using HTTPS URLs. For example, to push an image to your repository, you can use a command like this:

docker push https://gitlab.example.com/registry/my-repository/my-image

Remember to replace the example URLs with the actual URLs for your GitLab server and container repository.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Nimbus Code.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.