CompTIA Linux+ (XK0-005) — Question 56

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?

Answer options

Correct answer: B

Explanation

The correct option is B because it uses 'docker rm' in conjunction with '$(docker ps -aq)', which lists all container IDs, including those that are exited, and removes them. Option A is incorrect because 'docker rm --all' is not a valid command. Option C is unrelated as it pertains to cleaning up images, not containers. Option D is also incorrect since 'docker rm --state exited' is not a valid syntax for removing exited containers.