nerdexam
DockerDocker

DCA · Question #45

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

The correct answer is C: 'docker run -d --restart unless-stopped redis'. The docker run command uses the --restart flag with the unless-stopped policy to ensure a container automatically restarts unless manually stopped or the Docker daemon is restarted.

Submitted by asante_acc· Apr 18, 2026Installation and Configuration

Question

Which of the following commands starts a Redis container and configures it to always restart unless it is explicitly stopped or Docker is restarted?

Options

  • A'docker run -d --restart-policy unless-stopped redis'
  • B'docker run -d --restart omit-stopped redis'
  • C'docker run -d --restart unless-stopped redis'
  • D'docker run -d --failure omit-stopped redis'

Explanation

The docker run command uses the --restart flag with the unless-stopped policy to ensure a container automatically restarts unless manually stopped or the Docker daemon is restarted.

Common mistakes.

  • A. The correct flag for setting a restart policy is --restart, not --restart-policy.
  • B. omit-stopped is not a valid restart policy; the correct policy for this behavior is unless-stopped.
  • D. --failure is not a valid docker run flag for restart configuration, and omit-stopped is not a valid policy.

Concept tested. Docker container restart policies

Reference. https://docs.docker.com/config/containers/container-start-options/#restart-policies

Topics

#docker run#Restart policies#Container lifecycle#Container management

Community Discussion

No community discussion yet for this question.

Full DCA PracticeBrowse All DCA Questions