Error response from daemon: No such container: web means Docker has no container with that name or id. When the stack was started with Compose, the service is called web but the container is not: here it was fix10-dc-p6-web-1. Use the real container name with docker commands, or use docker compose commands, which take the service name.

docker ps -a --format shows the real names in one line each, and docker compose logs web works from the folder that holds the compose file.

The error

> docker logs web
Error response from daemon: No such container: web
exit=1

> docker exec web ls /
Error response from daemon: No such container: web
exit=1

> docker stop web
Error response from daemon: No such container: web
exit=1

The compose file that started the container:

name: fix10-dc-p6
services:
  web:
    image: alpine
    command: ["sh", "-c", "echo web started; sleep 600"]

Why it happens

docker logs, docker exec and docker stop look up a container by its name or id. Compose named this container after the project, the service and a number: the up output says Container fix10-dc-p6-web-1 Created, and docker ps -a listed the same name. None of the three plain docker commands accepted web; each answered with this message and exit code 1.

The project part of the name came from the name: line at the top of this compose file, so check that line (or the project your stack runs under) before guessing a container name.

The fix

> docker ps -a --format "{{.Names}}\t{{.Image}}\t{{.Status}}" --filter label=com.docker.compose.project=fix10-dc-p6
fix10-dc-p6-web-1	alpine	Up Less than a second

> docker logs fix10-dc-p6-web-1
web started
exit=0

> docker compose logs web
web-1  | web started
exit=0

Either form works: the full container name with docker, or the service name with docker compose run in the project folder. The label filter narrows the list to one Compose project; drop it to see every container. Keep the -a: after docker stop fix10-dc-p6-web-1, plain docker ps printed nothing for the project, and docker ps -a still listed fix10-dc-p6-web-1 Exited (137) Less than a second ago.

A second case gives the same message with the right name: the container no longer exists. A container started with --rm is removed when it exits:

> docker run --rm --name fix10-dc-gone alpine true
exit=0

> docker logs fix10-dc-gone
Error response from daemon: No such container: fix10-dc-gone
exit=1

How it was reproduced

A one-service compose file on the alpine image, started with docker compose up -d on Docker 29.9.3 and Docker Compose v5.7.0 on Windows, then docker logs, docker exec and docker stop with the service name. The commands ran from a cmd batch file with stderr merged into stdout; the batch file echoed each command with > before running it and printed its exit code after it. The project and container names are the test's own.

Frequently asked

Why does docker logs say No such container for my Compose service?
Compose names the container after the project, the service and a number, such as fix10-dc-p6-web-1 in the test. docker logs needs that name; docker compose logs takes the service name.
How do I list Docker container names?
Run docker ps -a --format with {{.Names}}. The -a flag includes stopped containers, which plain docker ps leaves out.
What is the difference between docker logs and docker compose logs?
docker logs takes one container name or id. docker compose logs takes service names from the compose file in the current project and prefixes each line with the service, as in web-1 | web started.

More decoded errors in the Fixes category.