Skip to main content
InterviewHubPRO
Section Overview
Q21

Question 21 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

42%
Docker & Containers (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)

What are Docker restart policies (`no`, `on-failure`, `always`, `unless-stopped`)?

senior LevelMost AskedDocker & ContainersSystem DesignHTTP & REST APIs

In Simple Words: Controls whether containers automatically restart after process termination or Docker daemon reboot:

  • no (Default): Container never restarts regardless of exit code.
  • on-failure[:max-retries]: Restarts only if the container exits with a non-zero exit code. Recommended for background batch jobs.
  • always: Always restarts the container regardless of exit code (even exit 0), and restarts on system reboot.
  • unless-stopped: Similar to always, but if the container was manually stopped (docker stop) prior to system shutdown, it will not restart when the Docker daemon restarts.