MidDocker

A container exits immediately on start. How do you debug it?

What they are really testing: Whether you have a systematic routine (logs, exit code, exec, inspect) and understand that a container lives only as long as its main foreground process.

A real interview question

A container exits immediately on start. How do you debug it?

What most people say

drag me

I would restart the container and see if it works.

A container that exits deterministically will just exit again. The cause is in the logs, the exit code, or the start command; restarting skips diagnosis entirely.

The follow-ups they ask next

  • A container exits with code 137. What does that tell you?

    137 = 128 + 9, killed by SIGKILL, most often an out-of-memory kill (exceeded the memory limit) or a forced stop. Check memory limits/usage and the OOM killer.

  • How do you get a shell in a container that crashes instantly?

    Override the entrypoint: docker run -it --entrypoint sh (or bash) <image>, which starts a shell instead of the failing command so you can inspect the filesystem, env, and run the command manually.

What the interviewer is listening for

  • Knows container life = main process life
  • Uses logs + exit code + inspect
  • Overrides entrypoint to get a shell

What sinks the answer

  • Just restarts it
  • Cannot read or interpret the exit code
  • No way to inspect a fast-failing container

If you genuinely do not know

Say this instead of freezing. Reasoning out loud from what you do know beats silence every single time, and a good interviewer is listening for exactly that.

A container [lives only as long as its main process], so I check what it did. [docker logs for stdout/stderr, ps -a + inspect for the exit code, e.g. 137 = OOM/SIGKILL]. If it dies too fast, [override the entrypoint to a shell and run it by hand]. Usual causes: [a command that exits, missing env/config, bad path, startup crash, or a backgrounded PID 1].

Keep going with docker

All 336 cloud engineer questions

Knowing the answer is not the same as recalling it under pressure

Sign in to send the questions you fumble to spaced recall, so they come back right before you would forget them, and learn the concepts behind them with hands-on labs.

Start free