Maven / GitLab CI Basics Interview Questions
What are 'services' in GitLab CI/CD and how do you use them?
Services are Docker containers that run alongside the main job container, providing supporting infrastructure like databases, message brokers, or a Docker daemon. They share a network namespace with the job container.
# Run tests with a PostgreSQL database service: test-with-db: stage: test image: python:3.12 services: - postgres:16-alpine # starts a Postgres container variables: POSTGRES_DB: testdb POSTGRES_USER: postgres POSTGRES_PASSWORD: secret DATABASE_URL: "postgresql://postgres:secret@postgres/testdb" script: - pip install -r requirements.txt - python -m pytest # Multiple services: integration-test: image: node:20 services: - redis:7-alpine - postgres:16-alpine - name: rabbitmq:3-management alias: rabbit # access as "rabbit" hostname script: - npm test # Service with alias and entrypoint override: custom-service: services: - name: my-registry/my-service:latest alias: api-mock entrypoint: ["/usr/bin/api-mock"] command: ["--port", "8080"]
Services are accessible from the main job container using the service's image name (or alias) as the hostname. For example, a postgres:16 service is reached at hostname postgres. Set an alias when you need a custom hostname.
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...
