Exited (0) Docker Origin: Platform & cloud OSI layer 7 · Application Last updated 13 Oct 2026

Docker container exits immediately (Exited (0) / Exited (1) right after start)

The container started and its main process finished at once, so the container stopped — Docker containers only live as long as PID 1.

Exact message you may see container exits immediatelycontainer stops right after startingExited (0) seconds ago
Seen on: Docker

Meaning

A container isn’t a VM: when CMD finishes, the container exits. Exited (0) means the command succeeded and ended (e.g. a script, or a service that daemonised into the background). Exited (1)/(2) means it crashed — the reason is in docker logs.

Common causes

  • CMD runs a short task, not a long-running server
  • Service starts in background/daemon mode (nginx without daemon off, service x start)
  • App crashes on startup — missing env var, config or DB
  • Running an OS image (ubuntu) with no command

⚡ Quick fix

  1. Read the output: docker logs <container>
  2. Run the server in the foreground (nginx -g 'daemon off;')
  3. For debugging keep it alive: docker run -it image sh

Detailed fix by platform

Docker

  1. bash
    docker ps -a --format '{{.Names}}\t{{.Status}}'
    docker logs --tail 50 mycontainer

Dockerfile

  1. CMD ["nginx", "-g", "daemon off;"]

How to diagnose

  1. Exit code — docker inspect -f '{{.State.ExitCode}}' c
  2. Logs — Last lines of docker logs
  3. Command — What does CMD/ENTRYPOINT run?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):

500.30 — HTTP Error 500.30 - ASP.NET Core app failed to start (.NET)500.3057P03 — FATAL: the database system is starting up (PostgreSQL)57P03ACR unauthorized — Azure Container Registry: unauthorized: authentication required, visit https://aka.ms/acr/authorization (AKS ErrImagePull 401) (Azure)ACR unauthorizedCannotPullContainerError — ECS task stopped: CannotPullContainerError: pull image manifest has been retried ... / ref pull has been retried (AWS)CannotPullContainerEr…Conflict container name — Conflict. The container name "/x" is already in use by container … (Docker)Conflict container na…Container failed to start — Cloud Run: The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable (Google Cloud / Firebase)Container failed to s…CrashLoopBackOff — Kubernetes: CrashLoopBackOff (Kubernetes)CrashLoopBackOffEssential container in task exited — ECS: Essential container in task exited (task keeps stopping) (AWS)Essential container i…Exited (0)

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.