Canonical: https://weaveos.com/reference/docker/read-container-logs

1. [Software capabilities](https://weaveos.com/reference)
2. /[Docker](https://weaveos.com/reference/docker)
3. /Read Docker container logs

Docker capability

# Read Docker container logs

Use docker logs for a quick check of container output. Call the Engine API or Docker SDK when a program needs to fetch the same log stream.

Documentation reviewed November 26, 2026

## Ways to do it

CLI

### docker container logs \<container>

Print a container’s captured output. Use --tail for recent lines and --follow to keep reading new output.

- Requirements

  Docker CLI connected to the right daemon, with access to the container name or ID.

- Limitations

  It reads captured standard output and error. Logs written only to files inside the container may be absent.

Example

```
docker container logs --tail 50 "$CONTAINER"
```

[Read source: Docker CLI container logs ↗](https://docs.docker.com/reference/cli/docker/container/logs/)

API

### GET /containers/{id}/logs

Request standard output, standard error, or both from the Docker Engine API.

- Requirements

  Access to the Docker daemon and the container’s ID or name. Set stdout and stderr query parameters for the streams you need.

- Limitations

  The Engine API documents support for the json-file and journald logging drivers for this endpoint.

Example

```
GET /v1.52/containers/CONTAINER_ID/logs?stdout=true&stderr=true&tail=50
```

[Read source: Docker Engine API ContainerLogs ↗](https://docs.docker.com/reference/api/engine/version/v1.52/#tag/Container/operation/ContainerLogs)

SDK

### Container.logs()

Read a container’s captured output from Python. Pass tail to bound the result, or stream=True when you need incremental reads.

- Requirements

  A Docker SDK client with access to the daemon that owns the container.

- Limitations

  Without streaming, the returned data is bytes. Decode it before passing it to a text consumer.

[Read source: Docker SDK for Python container logs ↗](https://docker-py.readthedocs.io/en/stable/containers.html#docker.models.containers.Container.logs)

## More from Docker

[View all Docker capabilities →](https://weaveos.com/reference/docker)

- [Inspect Docker container configuration↗](https://weaveos.com/reference/docker/inspect-container-configuration)
