A DevOps engineer needs to ensure that a containerized web application always restarts automatically if the container exits unexpectedly. Which Docker run option should be used?
Trap 1: --restart=on-failure
Only restarts if container exits with non-zero code.
Trap 2: --restart=unless-stopped
Restarts except when container is stopped manually.
Trap 3: --restart=no
No restart policy.
- A
--restart=on-failure
Why wrong: Only restarts if container exits with non-zero code.
- B
--restart=unless-stopped
Why wrong: Restarts except when container is stopped manually.
- C
--restart=no
Why wrong: No restart policy.
- D
--restart=always
Always restarts regardless of exit status.