Cloud Computing
Docker
Subjective
Sep 30, 2025
How do you implement Docker container auto-restart policies?
Detailed Explanation
Docker restart policies automatically restart containers when they exit: 1) no (default): Never restart, 2) always: Always restart regardless of exit status, 3) unless-stopped: Restart unless manually stopped, 4) on-failure[:max-retries]: Restart only on failure. Examples: docker run --restart=always nginx, docker run --restart=on-failure:3 myapp, docker run --restart=unless-stopped redis. Docker Compose: restart: always, restart: on-failure, restart: unless-stopped. Use cases: always for critical services, on-failure for applications that may crash, unless-stopped for services that should survive reboots but respect manual stops. Monitoring: docker ps shows restart count, docker inspect shows restart policy. Best practices: Use unless-stopped for most services, Implement proper health checks, Monitor restart patterns, Set appropriate restart delays.
Discussion (0)
No comments yet. Be the first to share your thoughts!
Share Your Thoughts