Bird
Raised Fist0
Dockerdevops~20 mins

Deploying from CI/CD pipeline in Docker - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
CI/CD Docker Deployment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of Docker command in CI/CD
You run this command in your CI pipeline to build and tag a Docker image:

docker build -t myapp:latest .

What will be the output if the Dockerfile is missing in the current directory?
Docker
docker build -t myapp:latest .
ASuccessfully built and tagged myapp:latest
BBuild completed but image not tagged
CWarning: No Dockerfile specified, using default
DError response from daemon: Dockerfile not found
Attempts:
2 left
💡 Hint
Think about what Docker needs to build an image.
🔀 Workflow
intermediate
2:00remaining
Correct order of CI/CD deployment steps
Arrange these steps in the correct order for deploying a Dockerized app from a CI/CD pipeline:
A3,2,1,4
B2,3,1,4
C3,1,2,4
D1,3,2,4
Attempts:
2 left
💡 Hint
Think about building before testing and pushing.
❓ Troubleshoot
advanced
2:00remaining
Troubleshooting failed Docker push in CI
In your CI pipeline, the Docker push command fails with:

denied: requested access to the resource is denied

What is the most likely cause?
Docker
docker push myregistry.com/myapp:latest
AYou are not logged in to the Docker registry
BThe Dockerfile has syntax errors
CThe image was not built before push
DThe Docker daemon is not running
Attempts:
2 left
💡 Hint
Think about permissions and authentication.
🧠 Conceptual
advanced
2:00remaining
Why use multi-stage builds in CI/CD pipelines?
What is the main benefit of using multi-stage Docker builds in a CI/CD pipeline?
AIt automatically deploys the image after build
BIt allows running multiple containers simultaneously
CIt reduces the final image size by separating build and runtime stages
DIt speeds up the Docker daemon startup time
Attempts:
2 left
💡 Hint
Think about image size and efficiency.
✅ Best Practice
expert
2:00remaining
Secure handling of secrets in CI/CD Docker deployments
Which method is the safest way to handle sensitive environment variables (like passwords) during Docker image deployment in a CI/CD pipeline?
APass secrets as plain text arguments during docker build
BStore secrets in the CI/CD platform's secret manager and inject at runtime
CInclude secrets in the source code repository in a .env file
DHardcode secrets in the Dockerfile using ENV instructions
Attempts:
2 left
💡 Hint
Think about avoiding exposure of secrets in images or code.

Practice

(1/5)
1. What is the main purpose of using a CI/CD pipeline when deploying Docker applications?
easy
A. To manually update Docker images on each server
B. To write Dockerfiles faster
C. To automate building, testing, and deploying Docker containers
D. To monitor server hardware performance

Solution

  1. Step 1: Understand CI/CD pipeline role

    A CI/CD pipeline automates repetitive tasks like building and deploying software.
  2. Step 2: Apply to Docker deployment

    For Docker apps, it automates building images, pushing them, and deploying containers.
  3. Final Answer:

    To automate building, testing, and deploying Docker containers -> Option C
  4. Quick Check:

    Automation = CI/CD pipeline purpose [OK]
Hint: CI/CD pipelines automate repetitive Docker deployment tasks [OK]
Common Mistakes:
  • Thinking CI/CD is for manual updates
  • Confusing CI/CD with monitoring tools
  • Believing CI/CD only speeds up coding
2. Which of the following is the correct Docker command to push an image to a registry in a CI/CD pipeline?
easy
A. docker run myimage:latest
B. docker pull myimage:latest
C. docker build myimage:latest
D. docker push myimage:latest

Solution

  1. Step 1: Identify the command to upload images

    The docker push command uploads images to a registry.
  2. Step 2: Confirm correct syntax

    docker push myimage:latest correctly pushes the image tagged 'latest'.
  3. Final Answer:

    docker push myimage:latest -> Option D
  4. Quick Check:

    Push = upload image [OK]
Hint: Push uploads images; pull downloads images [OK]
Common Mistakes:
  • Using pull instead of push to upload
  • Using build or run commands to push
  • Missing image tag in push command
3. Given this snippet in a CI/CD pipeline YAML file:
steps:
  - name: Build image
    run: docker build -t myapp:1.0 .
  - name: Push image
    run: docker push myapp:1.0
  - name: Deploy
    run: kubectl set image deployment/myapp myapp=myapp:1.0

What will happen after this pipeline runs successfully?
medium
A. The Kubernetes deployment will update to use the new Docker image tagged 1.0
B. The Docker image will be deleted from the registry
C. The deployment will roll back to the previous image
D. The Docker image will only be built locally without pushing

Solution

  1. Step 1: Analyze build and push steps

    The pipeline builds the image tagged 'myapp:1.0' and pushes it to the registry.
  2. Step 2: Analyze deployment step

    The command updates the Kubernetes deployment to use the new image 'myapp:1.0'.
  3. Final Answer:

    The Kubernetes deployment will update to use the new Docker image tagged 1.0 -> Option A
  4. Quick Check:

    Build + push + deploy = update deployment [OK]
Hint: Build, push, then deploy updates the app [OK]
Common Mistakes:
  • Assuming image is only local, not pushed
  • Thinking deployment rolls back automatically
  • Confusing deployment update with image deletion
4. A CI/CD pipeline fails at the deployment step with the error: kubectl: error: no deployment found. What is the most likely cause?
medium
A. The Docker image failed to build
B. The Kubernetes deployment name is incorrect or missing
C. The Docker push command was missing
D. The pipeline YAML syntax is invalid

Solution

  1. Step 1: Understand the error message

    The error says no deployment found, meaning Kubernetes cannot find the named deployment.
  2. Step 2: Identify cause in deployment step

    This usually happens if the deployment name in the kubectl set image command is wrong or missing.
  3. Final Answer:

    The Kubernetes deployment name is incorrect or missing -> Option B
  4. Quick Check:

    No deployment found = wrong deployment name [OK]
Hint: Check deployment name spelling in kubectl command [OK]
Common Mistakes:
  • Blaming build or push steps for deployment error
  • Ignoring error details about deployment not found
  • Assuming YAML syntax error without checking logs
5. You want to deploy a new version of your Docker app automatically only if tests pass in your CI/CD pipeline. Which sequence of steps is best to ensure this?
hard
A. Run tests -> Build Docker image -> Push image -> Deploy to production
B. Build Docker image -> Push image -> Run tests -> Deploy to production
C. Push image -> Run tests -> Build Docker image -> Deploy to production
D. Deploy to production -> Run tests -> Build Docker image -> Push image

Solution

  1. Step 1: Understand the logical order for safe deployment

    Tests must run first to verify code correctness before building and deploying.
  2. Step 2: Confirm correct step sequence

    After tests pass, build the Docker image, push it to the registry, then deploy to production.
  3. Final Answer:

    Run tests -> Build Docker image -> Push image -> Deploy to production -> Option A
  4. Quick Check:

    Tests first, then build, push, deploy [OK]
Hint: Always test before building and deploying [OK]
Common Mistakes:
  • Building or pushing before tests pass
  • Deploying before tests run
  • Running tests after deployment
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard