Skip to main content
InterviewHubPRO
Section Overview
Q16

Question 16 of 50

Part 2: Advanced Workflows, Security & Containerization (Mid-Level)

32%
CI/CD & GitHub Actions (50 Qs)•Part 2: Advanced Workflows, Security & Containerization (Mid-Level)

How do you run Containerized Jobs and Service Containers?

mid LevelCode ExampleSecurity & AuthDocker & Containers

In Simple Words:

  • container: forces the entire job to execute inside a specified Docker image rather than the host VM.
  • services: provisions isolated background containers (PostgreSQL, Redis, RabbitMQ) networked to the job container via localhost.
yaml
jobs:
  integration-tests:
    runs-on: ubuntu-latest
    services:
      postgres:
        image: postgres:16
        env:
          POSTGRES_DB: testdb
          POSTGRES_PASSWORD: secretpassword
        ports:
          - 5432:5432
        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
    steps:
      - uses: actions/checkout@v4
      - run: npm test
        env:
          DATABASE_URL: postgres://postgres:secretpassword@localhost:5432/testdb