> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/rtk-ai/rtk/llms.txt
> Use this file to discover all available pages before exploring further.

# rtk docker

> Docker commands with compact output

## Overview

Proxy for Docker CLI with token-optimized output. Compacts container lists, image names, and log output.

## Syntax

```bash theme={null}
rtk docker <SUBCOMMAND> [OPTIONS]
```

## Subcommands

### rtk docker ps

List containers with compact output.

```bash theme={null}
rtk docker ps [OPTIONS]
```

**-a, --all** `flag`

Show all containers (default shows just running)

**Output:**

```
3 containers (2 running):
✅ web (nginx:latest) :80→8080 [10h]
✅ api (node:18) :3000→3000 [10h]
⏹️  db (postgres:15) [stopped]
```

**Token savings: 70%**

### rtk docker images

List images with shortened names.

```bash theme={null}
rtk docker images [OPTIONS]
```

**Output:**

```
5 images (total: 2.1GB):
nginx:latest      142MB   [2 days ago]
node:18-alpine    165MB   [1 week ago]
postgres:15       379MB   [2 weeks ago]
... +2 more
```

**Token savings: 65%**

### rtk docker logs

Deduplicated log output.

```bash theme={null}
rtk docker logs <CONTAINER> [OPTIONS]
```

**-f, --follow** `flag`

Follow log output

**--tail \<n>** `number`

Number of lines to show from end

**Features:**

* Deduplicates repeated log lines (shows count)
* Strips timestamps and container IDs
* Groups similar messages

**Token savings: 80%**

## Examples

### List Running Containers

```bash theme={null}
rtk docker ps
```

### View Recent Logs

```bash theme={null}
rtk docker logs my-container --tail 50
```

### List All Images

```bash theme={null}
rtk docker images
```

## Implementation

Source: `src/container.rs`

### Optimizations

* **Port compaction**: `:8080→80` instead of full `0.0.0.0:8080->80/tcp`
* **Image shortening**: `nginx:latest` instead of full SHA
* **Status icons**: `✅` running, `⏹️` stopped, `🔄` restarting
* **Time formatting**: `10h` instead of verbose timestamps

## Related Commands

* [rtk kubectl](/api/kubectl.md) - Kubernetes operations
* [rtk log](/api/log) - Log filtering

## Token Savings Summary

| Command | Standard | RTK | Savings |
| - | - | - | - |
| `ps` | \~600 tokens | \~180 tokens | 70% |
| `images` | \~450 tokens | \~160 tokens | 65% |
| `logs` | \~2000 tokens | \~400 tokens | 80% |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.