Bird
0
0

You want to run Cypress tests inside Docker but need to pass environment variables for API keys. Which is the best approach?

hard📝 Conceptual Q8 of 15
Cypress - CI/CD and Reporting
You want to run Cypress tests inside Docker but need to pass environment variables for API keys. Which is the best approach?
AUse Docker's -e option to pass environment variables to the container
BHardcode API keys inside Cypress test files before running Docker
CMount a file with API keys and read it inside tests without Docker options
DSet environment variables only on the host machine, no Docker changes needed
Step-by-Step Solution
Solution:
  1. Step 1: Identify how to pass env variables to Docker containers

    Docker supports passing env variables with the '-e' flag.
  2. Step 2: Evaluate other options

    Hardcoding is insecure; mounting file without Docker env passing is unreliable; host env vars alone don't reach container.
  3. Final Answer:

    Use Docker's -e option to pass environment variables to the container -> Option A
  4. Quick Check:

    Pass env vars with -e flag in Docker [OK]
Quick Trick: Use '-e' to pass env vars into Docker container [OK]
Common Mistakes:
  • Hardcoding secrets in test files
  • Ignoring Docker env variable passing
  • Assuming host env vars auto-propagate

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes