Maven / GitLab CI Basics Interview Questions
What is the GitLab Container Registry and how do you use it in CI/CD pipelines?
The GitLab Container Registry is a built-in Docker image registry integrated with every GitLab project. It provides a private place to store and manage Docker images, directly accessible from CI/CD pipelines using predefined variables.
# Build and push to the GitLab Container Registry: build-image: stage: build image: docker:27 services: - docker:27-dind variables: DOCKER_TLS_CERTDIR: "/certs" before_script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY script: - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA . - docker build -t $CI_REGISTRY_IMAGE:latest . - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA - docker push $CI_REGISTRY_IMAGE:latest # Pull from registry in a later job: deploy-job: stage: deploy script: - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA - docker run -d $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
| Variable | Value |
|---|---|
| $CI_REGISTRY | registry.gitlab.com (or your instance's registry URL) |
| $CI_REGISTRY_IMAGE | Full path: registry.gitlab.com/group/project |
| $CI_REGISTRY_USER | GitLab CI token username (gitlab-ci-token) |
| $CI_REGISTRY_PASSWORD | GitLab CI token (auto-generated job token) |
The docker:dind (Docker-in-Docker) service is required when building Docker images inside a Docker-based runner. The DOCKER_TLS_CERTDIR variable enables TLS for Docker-in-Docker communication, which is required in modern versions of Docker.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
