Bird
0
0

In a CI/CD pipeline, you want to deploy a Docker container with environment variables set from pipeline secrets. Which command correctly passes an environment variable 'API_KEY' to the container?

hard📝 Application Q9 of 15
Docker - in CI/CD
In a CI/CD pipeline, you want to deploy a Docker container with environment variables set from pipeline secrets. Which command correctly passes an environment variable 'API_KEY' to the container?
Adocker run --env-file API_KEY myapp:latest
Bdocker run -e API_KEY=$API_KEY myapp:latest
Cdocker run -env API_KEY myapp:latest
Ddocker run --set-env API_KEY myapp:latest
Step-by-Step Solution
Solution:
  1. Step 1: Recall Docker environment variable syntax

    Use '-e VAR=value' or '-e VAR' to pass env vars to containers.
  2. Step 2: Identify correct option

    docker run -e API_KEY=$API_KEY myapp:latest uses '-e API_KEY=$API_KEY' which passes the pipeline secret to container.
  3. Final Answer:

    docker run -e API_KEY=$API_KEY myapp:latest -> Option B
  4. Quick Check:

    Pass env var with -e flag [OK]
Quick Trick: Use '-e VAR=value' to pass env vars to Docker containers [OK]
Common Mistakes:
  • Using incorrect flags like --env-file with single var
  • Using '-env' or '--set-env' which are invalid
  • Not expanding pipeline secret variable

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes