> For the complete documentation index, see [llms.txt](https://vives.gitbook.io/docker/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vives.gitbook.io/docker/inspecting-containers.md).

# Inspecting containers

### Logs

Containers running in the background almost always have applications that output some information to logs. This output is captured by Docker by default. This information can be viewed with the `docker logs` command.

```
 docker logs <containerIdOrName>
```

It is also possible to keep the log open. Any new additions to the log will be appended in real time to the terminal. This can be achieved with the `-f` or `--follow` attribute in the command.

```
 docker logs <containerIdOrName> --follow
```

{% embed url="<https://docs.docker.com/engine/reference/commandline/logs/>" %}

### Docker exec

Even when a container is running in the background, it is possible to execute commands inside that container. A popular command is `bash`. This effectively launches a shell process and enables you to view and interact with the container. You could compare this with an SSH session into the container.

```
docker exec -it <containerIdOrName> bash
```

{% embed url="<https://docs.docker.com/engine/reference/commandline/exec/>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://vives.gitbook.io/docker/inspecting-containers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
