mediumMultiple SelectObjective-mapped
XK0-006 Practice Question: Which TWO options are valid ways to pass…
Which TWO options are valid ways to pass environment variables to a Docker container?
⚠ Common exam trap
Many candidates confuse the `-v` flag (used for volumes) with environment variable flags, or assume `--var` or `--variable` are valid Docker options when they are not.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
--env-file file
The `--env-file` flag allows you to pass a file containing environment variables to a Docker container, where each line in the file is in `KEY=value` format. Option C is correct because the `-e` (or `--env`) flag directly sets an environment variable inside the container, e.g., `-e VAR=value`. Both are standard Docker CLI methods for injecting environment variables at container runtime.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
--var VAR=value
Why it's wrong here
--var is not a valid Docker option.
- ✓
--env-file file
Why this is correct
This loads environment variables from a file.
- ✓
-e VAR=value
Why this is correct
This is a standard way to set environment variables in Docker.
- ✗
--variable VAR=value
Why it's wrong here
--variable is not a valid Docker option.
- ✗
-v VAR=value
Why it's wrong here
-v is used for mounting volumes.
Go deeper
Related to this question
Learn chapter
File Permissions and Ownership
Key term
Value
Value is the perceived worth, benefit, or usefulness that a service, product, or activity delivers to stakeholders, especially customers and the business.
Key term
CLI
A CLI (command-line interface) is a text-based way to interact with a computer's operating system by typing commands instead of clicking icons.
About these practice questions
One of 979 original XK0-006 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This XK0-006 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the XK0-006 exam.