nerdexam
DockerDocker

DCA · Question #4

DCA Question #4: Real Exam Question with Answer & Explanation

The correct answer is C: 'docker run --rm -v /foo busybox'. The --rm flag with docker run ensures that both the container and any anonymous volumes it created are automatically removed upon exit.

Submitted by parkjh· Apr 18, 2026Storage and Volumes

Question

Which one of the following commands will result in the volume being removed automatically once the container has exited?

Options

  • A'docker run --del -v /foo busybox'
  • B'docker run --read-only -v /foo busybox'
  • C'docker run --rm -v /foo busybox'
  • D'docker run --remove -v /foo busybox'

Explanation

The --rm flag with docker run ensures that both the container and any anonymous volumes it created are automatically removed upon exit.

Common mistakes.

  • A. --del is not a valid command-line option for the docker run command.
  • B. --read-only makes the container's root filesystem immutable, but it does not control the automatic removal of volumes when the container exits.
  • D. --remove is not a valid command-line option for docker run; the correct flag for automatic removal is --rm.

Concept tested. Automatic container and volume cleanup

Reference. https://docs.docker.com/engine/reference/commandline/run/#clean-up---rm

Topics

#Docker run command#Volume Management#Container Lifecycle#Anonymous Volumes

Community Discussion

No community discussion yet for this question.

Full DCA PracticeBrowse All DCA Questions