# Forward Docker container logs with Fluent Bit

Docker's default `json-file` logging driver writes each container's stdout and stderr to a file on the host. Fluent Bit can tail those files and forward them to Tailcove, so every container's output becomes searchable without changing the containers.

## 1. Create a source

Create a source in Tailcove for the host, for example `docker-host-1`, and copy its ingest token.

## 2. Write the Fluent Bit config

Create `fluent-bit.conf`:

```ini
[SERVICE]
    Parsers_File      parsers.conf

[INPUT]
    Name              tail
    Path              /var/lib/docker/containers/*/*.log
    Parser            docker
    Tag               docker.*
    Refresh_Interval  5

[FILTER]
    Name              record_modifier
    Match             docker.*
    Record            host ${HOSTNAME}

[OUTPUT]
    Name              http
    Match             docker.*
    Host              ingest.tailcove.dev
    Port              443
    URI               /api/v1/logs
    Format            json_lines
    Json_Date_Key     time
    Json_Date_Format  iso8601
    tls               On
    Header            Authorization Bearer ${TAILCOVE_TOKEN}
```

Docker's log records name the raw line `log`; Tailcove maps `log` to `message` and `time` to the timestamp, so no renaming filter is needed. The `record_modifier` filter adds the host name, which Tailcove stores in its own `host` column.

## 3. Run Fluent Bit as a container

```bash
docker run -d --name fluent-bit \
  -e TAILCOVE_TOKEN=YOUR_INGEST_TOKEN \
  -e HOSTNAME=$(hostname) \
  -v /var/lib/docker/containers:/var/lib/docker/containers:ro \
  -v $(pwd)/fluent-bit.conf:/fluent-bit/etc/fluent-bit.conf:ro \
  fluent/fluent-bit
```

The container directory is mounted read-only; Fluent Bit only needs to read the log files.

## 4. Verify it works

Start any container that writes to stdout:

```bash
docker run --rm alpine echo "hello from a container"
```

Open the source's **Live tail** in Tailcove; the line arrives within a few seconds.

## 5. Search by host

Because each line carries `host`, you can narrow a busy source to one machine:

```
host:docker-host-1 "connection refused"
```

## Tips

- If your containers already log JSON, their fields stay inside the `log` string. Emitting a `level` field from the app and adding a Fluent Bit parser for it lets you filter on `level:error`.
- Prefer a header other than `Authorization`? Tailcove also accepts `X-Tailcove-Token`.

## Next steps

- Prefer Vector? See [Vector log collection](https://tailcove.dev/guides/vector-server-logs).
- Full field mapping in the [Fluent Bit reference](https://tailcove.dev/docs/sending-logs/fluentbit).
