Delivery & cloudInterview preparation
Intermediate·Scenario·2 min read

The container exits immediately. What should I check?

Practice this question

Definition:

A container stays running while its main process remains alive. An immediate exit usually means the command finished, failed startup or was killed, rather than that Docker randomly stopped a healthy application. Logs, exit status and runtime configuration tell you which case occurred.

Key points:

  • Read logs and the exit code; check the startup command and missing configuration.

  • Confirm required files, dependencies and permissions exist in the image.

  • The main process must keep running; starting it in the background can make the container exit.

  • Inspect memory limits and termination reasons if the process was killed without a normal application exception.

Interview point:

  • Fix the foreground process or startup failure rather than adding an endless sleep to keep a broken container alive.
Adapted from 09_TESTING_GIT_DOCKER_CLOUD.md · “The container exits immediately. What should I check?”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.