Maven / GitLab CI Basics Interview Questions
How do you use the 'image' keyword to specify a Docker environment for a job?
The image keyword specifies the Docker image that the runner uses as the execution environment for the job. This ensures each job runs in a consistent, isolated environment with all required tools pre-installed.
# Set a default image for all jobs default: image: ubuntu:24.04 # Override image for a specific job build-node: stage: build image: node:20-alpine # uses Node.js 20 script: - node --version - npm ci - npm run build build-python: stage: build image: python:3.12-slim # different image for Python job script: - pip install -r requirements.txt - python -m pytest # Image with a registry prefix deploy-job: image: registry.gitlab.com/myorg/myimage:latest script: - ./deploy.sh # Image with a specific SHA (for reproducibility) test-job: image: name: node:20-alpine entrypoint: [""] # override the entrypoint if needed script: - npm test
Without a Docker executor: the image keyword is only used by runners with a Docker, Kubernetes, or similar container-based executor. Runners using the Shell executor ignore the image keyword and run jobs directly on the host machine.
Default image: if you don't specify an image, GitLab.com runners use a default image (often a Ruby image). Always specify an explicit image for consistent, predictable environments.
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...
