nerdexam
CompTIA

CV0-004 · Question #235

A cloud engineer is reviewing the following Dockerfile to deploy a Python web application: Which of the following changes should the engineer make to the file to improve container security?

The correct answer is A. Add the instruction USER nonroot. Adding USER nonroot ensures that the application runs as a non-root user within the container, reducing the risk of privilege escalation and limiting the damage that could be done if the container is compromised. Running containers as root is generally discouraged for security

Security

Question

A cloud engineer is reviewing the following Dockerfile to deploy a Python web application:

Which of the following changes should the engineer make to the file to improve container security?

Options

  • AAdd the instruction USER nonroot.
  • BChange the version from latest to 3.11.
  • CRemove the instruction.
  • DEnsure myapp/main/py is owned by root.

How the community answered

(41 responses)
  • A
    83% (34)
  • B
    5% (2)
  • C
    10% (4)
  • D
    2% (1)

Explanation

Adding USER nonroot ensures that the application runs as a non-root user within the container, reducing the risk of privilege escalation and limiting the damage that could be done if the container is compromised. Running containers as root is generally discouraged for security

Topics

#Container Security#Dockerfile Best Practices#Principle of Least Privilege#Docker USER Instruction

Community Discussion

No community discussion yet for this question.

Full CV0-004 Practice