Skip to content

GitLab Container Registry

The GitLab Container Registry is a secure and private registry for Docker images. It allows you to build and push images from your CI/CD pipelines and pull images for deployment.

Log in to GitLab Registry with Docker

You need to be authenticated to be able to push images. It does not matter if the project is private or public.

docker login
docker push

CI/CD integration

The following example demonstrates how to build and push a Docker image to the GitLab registry.

Create a project with a Dockefile and .gitlab-ci.yml.

FROM alpine:latest
CMD echo "Hello, World!"

Copy and paste the following file into your project. It uses the kaniko-project to build the image using Kubernetes.

  - build

  stage: build
    entrypoint: [""]
    - /kaniko/executor
      --context "${CI_PROJECT_DIR}"
      --dockerfile "${CI_PROJECT_DIR}/Dockerfile"
      --destination "${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}"
        - Dockerfile

This setup builds and pushes an image to the registry when a commit is made to Dockerfile in the default branch. The image is tagged with the commit tag, or latest if no tag is provided.

You can view the images in the project's registry by navigating to DeployContainer Registry.

Pull images

Pull images from the registry to deploy your application. The following example demonstrates how to pull an image from the registry:

docker pull
docker run
Hello, World!