Docker Core

An exec or attach targeted a container whose main process is not active.

container-is-not-running
MediumContainer Platform

Reviewed for reference consistency: August 11, 2026

An exec or attach targeted a container whose main process is not active.

What container-is-not-running Means

The container-is-not-running error on the Docker Core indicates an exec or attach targeted a container whose main process is not active.. This typically occurs due to the container's main process exited, taking the process namespace with it.

Exec sessions and attaches require a live process namespace to join. When the target container exited or was only created but never started, the daemon refuses the operation with the container-is-not-running condition and reports the container's actual state around it.

How to fix container-is-not-running

General informational guidance, not professional advice. Commands can affect your system or data — back up first and proceed at your own risk. FixerCode is an independent reference, not affiliated with any vendor mentioned.

  1. Show container state and exit codes

    Filtering the listing to exited containers reveals which workloads stopped and pairs with inspect for the exit code.

    docker ps -a --filter status=exited
  2. Read the final log lines of the container

    Tail logs show what the main process printed before exiting, which explains why the namespace closed.

    docker logs --tail 50 <container>

Technical Background

Containers are processes first: the executable namespace an exec joins exists only while the main process runs. Exit, crash, or non-start all converge to the same refusal because the join target is gone.

The condition differs from the lookup failure in an important way: the container still exists and its logs remain available, so post-mortem access is intact even though interactive access is not.

Common Causes

  • The container's main process exited, taking the process namespace with it
  • The container was created but a start step never ran
  • A crashed application left the container in exited state

Typical Scenarios

  • Opening a shell into a one-shot job container after its process finished
  • A debugging step in a pipeline running before the service container started
  • Attaching to a created-but-never-started container from a dry run

What to Know

Status output separates exited from running and shows the exit code, which distinguishes an application failure from a lifecycle ordering mistake in the surrounding automation.

Frequently Asked Questions

Common questions about Docker container-is-not-running error

Logs stay readable. They persist for the container's lifetime on disk, independent of the process being stopped.

A running state reopens the namespace, so exec works again after a start; the prior session's environment is not preserved.

Related Error Codes

Related Errors From Other Categories

Similar error codes documented across different platforms and systems