Desk Clarity

A field guide to everyday digital problems.

Developer tools / Practical guide

Docker Exec Says the Container Is Not Running: Inspect the Original Exit

docker exec starts an additional process in a running container.

By ON Lab2 min readSources checked November 10, 2026 (KST)

docker exec starts an additional process in a running container. It cannot repair a container whose primary process already exited. Inspect the exit state and startup output before trying to open a shell again.

Inspect the boundary before changing the service

The commands below use placeholder names. They illustrate a diagnostic workflow and were not run against a live container in this review. Match the Docker context and project before inspecting your own service.

docker ps -a --filter name=demo
docker inspect demo --format '{{json .State}}'
docker logs --tail 100 demo
docker inspect demo --format '{{json .Config.Entrypoint}} {{json .Config.Cmd}}'
# These are diagnostic examples; demo is a placeholder.

What to compare

A container exists as a record after its main process stops. That record can still have logs, configuration and a useful exit code. A successful short-lived job may exit with code zero; an exited container is not automatically broken. For a server, an immediate exit may instead point to missing configuration, an invalid entrypoint or an application error. The state object can also show an OOMKilled flag, but interpreting it requires the host limits and actual workload.

Choose the next action

Compare the intended lifecycle with the observed one. If it is a batch task, collect its output rather than making it idle forever. If it is a server, correct the startup cause in the managed configuration and restart through the normal owner workflow. Read restart policy and restart count before repeatedly invoking start. Keep the first failure evidence; rapid retries can hide the original useful message. If the image lacks a shell, a running container can also reject sh for that separate reason.

Limits and verification

Do not replace the entrypoint with tail -f merely to make a status indicator green. That can keep a container alive while the application remains down. This article provides a diagnostic sequence, not a command that changes existing services. Docker daemon runtime was unavailable in this review, so no exit or recovery on a real container is claimed.

Related: Docker Logs Is Empty: Check Where the Application Writes and Which Driver Collects It.

Official Docker documentation checked November 10, 2026 (KST). Docker Compose 2.35.1 configuration parsing was available, but the Docker daemon was not running. These pages do not claim a live container connectivity, storage, health or recovery test.

Sources & further reading