Docker and CI/CD · Junior · Question 14 of 75
Why does a container exit right after starting?
- 1Docker stops idle containers after a few seconds to save memory
- 2Containers must be started with
-d, or they exit at once - ✓Correct answer: Its main process finished, and the container lives only as long as it
Explanation
A container is its main process (PID 1). A script that finishes, or a server that crashes, ends the container. Check docker logs and the exit code in docker ps -a.