0
0
Jenkinsdevops~20 mins

Docker compose in pipelines in Jenkins - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Docker Compose Pipeline Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of Docker Compose Up in Jenkins Pipeline
What will be the output of the following Jenkins pipeline snippet when it runs the Docker Compose up command?
Jenkins
pipeline {
  agent any
  stages {
    stage('Start Services') {
      steps {
        script {
          sh 'docker-compose up -d'
        }
      }
    }
  }
}
AStarts all services defined in docker-compose.yml in detached mode and prints container IDs
BFails with error: 'docker-compose' command not found
CStarts services but runs in foreground blocking the pipeline
DPrints the docker-compose.yml content without starting services
Attempts:
2 left
💡 Hint
Think about what the '-d' flag does in docker-compose up command.
Configuration
intermediate
2:00remaining
Correct Jenkinsfile Syntax for Docker Compose
Which Jenkinsfile snippet correctly runs 'docker-compose down' to stop and remove containers in a pipeline stage?
Astage('Stop Services') { steps { sh 'docker-compose stop' } }
Bstage('Stop Services') { steps { sh docker-compose down } }
Cstage('Stop Services') { steps { sh "docker-compose down" } }
Dstage('Stop Services') { steps { sh 'docker-compose down' } }
Attempts:
2 left
💡 Hint
Check the correct way to pass shell commands as strings in Jenkins pipeline.
Troubleshoot
advanced
2:00remaining
Troubleshooting Docker Compose Service Not Starting
In a Jenkins pipeline, the 'docker-compose up' command runs but the service fails to start. Which is the most likely cause?
AThe docker-compose.yml file is missing the 'version' field
BThe Jenkins agent does not have Docker installed or running
CThe pipeline script uses 'sh' instead of 'bat' on Linux
DThe Jenkinsfile is missing the 'agent any' declaration
Attempts:
2 left
💡 Hint
Think about what is required for docker-compose commands to work on the Jenkins agent.
🔀 Workflow
advanced
2:00remaining
Best Practice for Using Docker Compose in Jenkins Pipeline
Which workflow step is best to ensure Docker Compose services are cleaned up after tests in a Jenkins pipeline?
ARun 'docker-compose rm -f' before 'docker-compose up'
BRun 'docker-compose stop' before starting services
CRun 'docker-compose down' in a post-build cleanup stage
DRun 'docker-compose restart' after tests finish
Attempts:
2 left
💡 Hint
Consider how to properly remove containers and networks after pipeline completion.
🧠 Conceptual
expert
2:00remaining
Understanding Docker Compose Exit Codes in Jenkins
If a service in 'docker-compose up' fails to start, what exit code does the command return, and how should Jenkins handle it?
ANon-zero exit code; Jenkins should fail the pipeline immediately
BZero exit code; Jenkins continues regardless of service status
CNon-zero exit code; Jenkins ignores it by default and continues
DZero exit code; Jenkins retries the command automatically
Attempts:
2 left
💡 Hint
Think about how shell commands signal failure and Jenkins pipeline behavior.