- A
Maximize the number of layers to improve caching
Why wrong: More layers increase build time and may include unnecessary files.
- B
Run containers as a non-root user
Non-root users limit the impact of a container compromise.
- C
Use pinned SHA digests for base images
SHA digests provide immutable references, ensuring the exact image is used.
- D
Use the 'latest' tag for flexibility
Why wrong: The 'latest' tag is mutable and can lead to unexpected changes.
- E
Use old base images to avoid breaking changes
Why wrong: Old base images may contain unpatched vulnerabilities.
Best Practices for Securing Container Images
This CKS practice question tests your understanding of supply chain security. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.
Which two of the following are best practices for container image security? (Select TWO.)
Clue words in this question
Noticing these words before you look at the options changes how you read each choice.
Clue:
"best"Why it matters: Signals that multiple options may be partially correct. Choose the option that most directly solves the exact problem described, not the one that sounds most complete.
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
Run containers as a non-root user
Option B is correct because running containers as a non-root user follows the principle of least privilege, reducing the risk of privilege escalation if the container is compromised. By default, Docker containers run as root, but using the USER directive in the Dockerfile or specifying a non-root user at runtime (e.g., --user 1000) limits the attacker's ability to modify system files or escape the container.
Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Maximize the number of layers to improve caching
Why it's wrong here
More layers increase build time and may include unnecessary files.
- ✓
Run containers as a non-root user
Why this is correct
Non-root users limit the impact of a container compromise.
Clue confirmation
The clue word "best" in the question point toward this answer.
Related concept
Read the scenario before looking for a memorised answer.
- ✓
Use pinned SHA digests for base images
Why this is correct
SHA digests provide immutable references, ensuring the exact image is used.
Clue confirmation
The clue word "best" in the question point toward this answer.
Related concept
Read the scenario before looking for a memorised answer.
- ✗
Use the 'latest' tag for flexibility
Why it's wrong here
The 'latest' tag is mutable and can lead to unexpected changes.
- ✗
Use old base images to avoid breaking changes
Why it's wrong here
Old base images may contain unpatched vulnerabilities.
Common exam traps
Common exam trap: answer the scenario, not the keyword
A common trap is thinking that the 'latest' tag is safe for production because it always gets the newest version. Actually, 'latest' is mutable and can point to any arbitrary image, including malicious ones, making it a supply chain risk.
Detailed technical explanation
How to think about this question
Under the hood, container images are composed of read-only layers, each representing a filesystem diff. Pinning a base image to a SHA256 digest (e.g., FROM ubuntu@sha256:abc123) ensures that every pull retrieves the exact same filesystem content, preventing tampering or accidental upgrades. In a real-world scenario, a CI/CD pipeline that uses 'latest' could unknowingly pull a compromised image from a public registry, whereas a pinned digest guarantees reproducibility and integrity.
KKey Concepts to Remember
- Read the scenario before looking for a memorised answer.
- Find the constraint that changes the correct option.
- Eliminate answers that are true in general but not in this case.
TExam Day Tips
- Watch for words such as best, first, most likely and least administrative effort.
- Review why wrong options are wrong, not only why the correct option is correct.
Key takeaway
Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.
Real-world example
How this comes up in practice
A junior network technician can log in to a core router but cannot reach the enable prompt or configuration mode. The AAA server is authenticating the login — but the authorisation policy only grants privilege level 1, not 15. Authentication (who you are) is working; authorisation (what you can do) is not.
What to study next
Got this wrong? Here's your next step.
Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.
- →
Supply Chain Security — study guide chapter
Learn the concepts, then practise the questions
- →
Supply Chain Security practice questions
Targeted practice on this topic area only
- →
All CKS questions
997 questions across all exam domains
- →
Certified Kubernetes Security Specialist CKS study guide
Full concept coverage aligned to exam objectives
- →
CKS practice test guide
How to use practice tests most effectively before exam day
Related practice questions
Related CKS practice-question pages
Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.
Monitoring Logging and Runtime Security practice questions
Practise CKS questions linked to Monitoring Logging and Runtime Security.
Cluster Setup and Hardening practice questions
Practise CKS questions linked to Cluster Setup and Hardening.
System Hardening practice questions
Practise CKS questions linked to System Hardening.
Minimize Microservice Vulnerabilities practice questions
Practise CKS questions linked to Minimize Microservice Vulnerabilities.
Supply Chain Security practice questions
Practise CKS questions linked to Supply Chain Security.
Monitoring, Logging and Runtime Security practice questions
Practise CKS questions linked to Monitoring, Logging and Runtime Security.
Cluster Setup practice questions
Practise CKS questions linked to Cluster Setup.
Cluster Hardening practice questions
Practise CKS questions linked to Cluster Hardening.
CKS fundamentals practice questions
Practise CKS questions linked to CKS fundamentals.
CKS scenario practice questions
Practise CKS questions linked to CKS scenario.
CKS troubleshooting practice questions
Practise CKS questions linked to CKS troubleshooting.
Practice this exam
Start a free CKS practice session
Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.
FAQ
Questions learners often ask
What does this CKS question test?
Supply Chain Security — This question tests Supply Chain Security — Read the scenario before looking for a memorised answer..
What is the correct answer to this question?
The correct answer is: Run containers as a non-root user — Option B is correct because running containers as a non-root user follows the principle of least privilege, reducing the risk of privilege escalation if the container is compromised. By default, Docker containers run as root, but using the USER directive in the Dockerfile or specifying a non-root user at runtime (e.g., --user 1000) limits the attacker's ability to modify system files or escape the container.
What should I do if I get this CKS question wrong?
Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.
Are there clue words in this question I should notice?
Yes — watch for: "best". Signals that multiple options may be partially correct. Choose the option that most directly solves the exact problem described, not the one that sounds most complete.
What is the key concept behind this question?
Read the scenario before looking for a memorised answer.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
7 more ways this is tested on CKS
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. Which of the following is a BEST practice for securing container images in a Dockerfile?
easy- ✓ A.Use the USER directive to specify a non-root user
- B.Store secrets in environment variables in the image
- C.Run the container as root to simplify permission management
- D.Use the 'latest' tag to always get the newest base image
Why A: The USER directive in a Dockerfile sets the user for the container process, and using a non-root user (e.g., USER 1000) follows the principle of least privilege. This reduces the attack surface by preventing an attacker who gains code execution from having root access to the host or container, which is a critical security requirement for containerized workloads.
Variation 2. Which of the following is a best practice for Dockerfiles to improve supply chain security?
medium- A.Use the latest tag for base images to get the newest features
- B.Run the container as root by default
- ✓ C.Use a distroless base image
- D.Hardcode secrets directly in the Dockerfile
Why C: Option C is correct because distroless base images contain only the application and its runtime dependencies, significantly reducing the attack surface by eliminating package managers, shells, and other utilities that could be exploited. This aligns with the principle of minimalism in supply chain security, as fewer components mean fewer potential vulnerabilities and a smaller blast radius in case of compromise.
Variation 3. Which of the following is a best practice for securing container images in a Kubernetes environment?
easy- A.Store secrets directly in the Dockerfile for convenience
- B.Run containers as root to have full access to system resources
- C.Use the latest tag for all base images to get the newest features
- ✓ D.Use minimal base images such as distroless or Alpine to reduce attack surface
Why D: Using minimal base images like distroless or Alpine reduces the attack surface by including only necessary packages, which is a key security best practice. Option D is correct. Option A is wrong because storing secrets in Dockerfile exposes them in image layers. Option B is wrong because running as root grants excessive privileges, increasing vulnerability. Option C is wrong because using the latest tag introduces unpredictable changes and potential vulnerabilities.
Variation 4. Which of the following is a best practice for securing container images in a CI/CD pipeline?
easy- ✓ A.Using a minimal base image such as Alpine
- B.Using the 'latest' tag for all base images to ensure the newest features
- C.Running the container as root to avoid permission issues
- D.Installing all available packages to ensure the application has all dependencies
Why A: Using a minimal base image like Alpine reduces the attack surface by minimizing the number of installed packages and potential vulnerabilities.
Variation 5. Which of the following is a best practice for securing container images?
easy- A.Run containers as root to ensure all permissions are available
- B.Use the 'latest' tag for base images to get the latest features
- ✓ C.Use distroless base images to minimize the attack surface
- D.Embed secrets directly in the Dockerfile for easy access
Why C: Option C is correct because distroless base images contain only the application and its runtime dependencies, omitting package managers, shells, and other utilities that could be exploited. This dramatically reduces the attack surface and aligns with the principle of least functionality, making it a best practice for securing container images in Kubernetes environments.
Variation 6. Which of the following is a best practice for securing container images?
medium- A.Hardcode passwords in Dockerfile as environment variables for convenience
- ✓ B.Use minimal base images like distroless or Alpine
- C.Use the latest tag for base images to get the newest features
- D.Run containers as root to simplify permission management
Why B: Option B is correct because using minimal base images like distroless or Alpine significantly reduces the attack surface by eliminating unnecessary packages, libraries, and utilities that could contain vulnerabilities. Distroless images contain only the application and its runtime dependencies, while Alpine uses musl libc and BusyBox to keep the image size small and minimize the number of Common Vulnerabilities and Exposures (CVEs) that need to be patched.
Variation 7. Which TWO of the following are best practices for securing the container supply chain? (Select 2)
medium- A.Disable image pull secrets to reduce complexity
- ✓ B.Scan container images for vulnerabilities
- C.Hardcode secrets in the Dockerfile for convenience
- ✓ D.Use minimal base images like Alpine or distroless
- E.Run containers as root to simplify permissions
Why B: Using minimal base images reduces the attack surface, and scanning images for vulnerabilities helps identify and fix security issues before deployment.
Keep practising
More CKS practice questions
- Which flag is used to restrict the kubelet's ability to modify node status and pods?
- A Falco rule has priority `WARNING` and output: `Sensitive file opened (user=%user.name command=%proc.cmdline file=%fd.n…
- Falco detects a shell being opened inside a container. Which Falco rule field is used to specify the syscall condition f…
- A security audit reveals that a ServiceAccount named 'monitor' has a ClusterRoleBinding to the cluster-admin role. What…
- Match each Kubernetes security component to its description.
- Match each Kubernetes certificate type to its usage.
Last reviewed: Jul 4, 2026
This CKS practice question is part of Courseiva's free CNCF 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 CKS exam.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.