nerdexam
Docker

DCA · Question #45

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

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'

How the community answered

(27 responses)
  • A
    4% (1)
  • B
    4% (1)
  • C
    93% (25)

Why each option

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.

A'docker run -d --restart-policy unless-stopped redis'

The correct flag for setting a restart policy is `--restart`, not `--restart-policy`.

B'docker run -d --restart omit-stopped redis'

`omit-stopped` is not a valid restart policy; the correct policy for this behavior is `unless-stopped`.

C'docker run -d --restart unless-stopped redis'Correct

The command 'docker run -d --restart unless-stopped redis' correctly starts a Redis container in detached mode (`-d`) and configures it with the `unless-stopped` restart policy. This policy ensures the container automatically restarts if it exits due to an error or a system reboot, but it will not restart if it is explicitly stopped using `docker stop` or if the Docker daemon itself is stopped.

D'docker run -d --failure omit-stopped redis'

`--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

Source: 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 Practice