Error response from daemon: No such container (Docker) — how to fix
Error response from daemon: No such container: myapp
Error: No such container: 3f2a1bc9d8e7
Quick fix: Run docker ps -a to list all containers, including stopped ones, and use the exact name or ID shown. With Compose use docker compose exec web sh (service name) instead of the container name. Check docker context ls and that you aren't mixing sudo docker and docker.
What it means
Commands like docker exec, docker logs, docker stop, docker rm and docker inspect look up a container by name or ID prefix. The daemon found no match. First see what actually exists:
docker ps -a --format 'table {{.ID}}\t{{.Names}}\t{{.Status}}\t{{.Image}}'
docker ps without -a only shows running containers.
Cause 1: Compose generated a different name
Compose names containers <project>-<service>-<index> (Compose v2, e.g. myapp-web-1) or <project>_<service>_1 (old v1). docker exec web fails; use the Compose command with the service name instead:
docker compose ps
docker compose exec web sh
docker compose logs -f web
Or set a fixed name in compose.yaml:
services:
web:
image: nginx
container_name: web
Cause 2: the container was removed
- Started with
docker run --rm: it is deleted as soon as it exits. docker compose downremoves the project's containers.docker system prune/docker container prunedelete stopped containers.- Restarting Docker Desktop or resetting it can wipe everything.
If it's gone, recreate it (docker run ... or docker compose up -d). To see why it exited before removal, run it without --rm and check docker logs <name>.
Cause 3: stale or wrong container ID
IDs change every time a container is recreated. Scripts that saved an ID earlier, or docker compose up after a config change, leave you with an old ID. Look containers up by name or label at runtime:
docker ps -q -f name=^myapp$
docker ps -q -f label=com.docker.compose.service=web
Cause 4: different daemon, context or user
Containers created with sudo docker (root daemon) are invisible to rootless Docker, and Docker Desktop on Linux uses its own context separate from the system Docker Engine.
docker context ls # the active one has a *
docker context use default
echo $DOCKER_HOST # an env var overrides the context
Use the same user and context that created the container.
Cause 5: errors during docker compose up
No such container: <id> during up usually means Compose's view is out of sync after a container was removed by hand. Clean up and recreate:
docker compose down --remove-orphans
docker compose up -d
If that doesn't help, docker compose up -d --force-recreate.
Last updated 2026-11-21.