nerdexam
CompTIACompTIA

XK0-005 · Question #1411

XK0-005 Question #1411: Real Exam Question with Answer & Explanation

The correct answer is B: docker rm $(docker ps -aq). {"question_number": 10, "question": "A Linux administrator found many containers in an exited state. Which of the following commands will allow the administrator to clean up the containers in an exited state?", "correct_answer": "B", "correct_answer_text": "docker rm $(docker ps

Scripting, Containers, and Automation

Question

A Linux administrator found many containers in an exited state. Which of the following commands will allow the administrator to clean up the containers in an exited state?

Options

  • Adocker rm --all
  • Bdocker rm $(docker ps -aq)
  • Cdocker images prune *
  • Ddocker rm --state exited

Explanation

{"question_number": 10, "question": "A Linux administrator found many containers in an exited state. Which of the following commands will allow the administrator to clean up the containers in an exited state?", "correct_answer": "B", "correct_answer_text": "docker rm $(docker ps -aq)", "explanation": "docker rm $(docker ps -aq) uses command substitution: docker ps -aq returns the IDs of all containers (both running and exited) using -a (all) and -q (quiet/IDs only), and docker rm removes them. Among the options given, this is the only syntactically valid command that actually removes containers. docker rm --all (option A) is not a valid Docker flag---all does not exist for docker rm. docker images prune * (option C) is incorrect syntax; the valid command is docker image prune (no wildcard), and it removes unused images, not containers. docker rm --state exited (option D) is not a valid Docker command; --state is not a recognized flag for docker rm.", "generated_by": "claude-sonnet", "llm_judge_score": 3}

Topics

#Docker#Container Management#CLI#Resource Management

Community Discussion

No community discussion yet for this question.

Full XK0-005 PracticeBrowse All XK0-005 Questions