advancedTop 100 Interview Questions
Why might a container exit immediately after `docker run`?
Most commonly because its main process (PID 1) completed and exited — a container's lifecycle is tied directly to its main process, so if that process isn't a long-running server/daemon (e.g., it was a one-shot script), the container stops as soon as it finishes.
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response