Skip to content

Commit 789d214

Browse files
vpeterssonclaude
andauthored
fix(compose): route container logs to journald to bound disk usage (#2853)
* fix(compose): route container logs to journald to bound disk usage Adds `logging: driver: journald` to all four services in docker-compose.yml.tmpl with per-service tags so the host's systemd-journald handles rotation/retention. Previously the default json-file driver wrote unbounded `*-json.log` files under /var/lib/docker/containers/, which on long-running Pi installs could fill the SD card (issue #2304 reported a 19 GB anthias-viewer log). Updates the docs to explain the new behavior and document `journalctl` access via the per-service `CONTAINER_TAG=` filter. Refs #2304 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix: cover anthias-caddy with journald driver, scope docs accurately Address Copilot review on #2853: - enable_ssl.sh's generated SSL override added anthias-caddy without a logging block, so the caddy sidecar would still write unbounded json-file logs. Add the journald driver + tag there too. - Docs implied no Anthias container writes json-file logs, which was not true once SSL was enabled. Scope the statement to the four core services plus the optional caddy sidecar. - Lead the journalctl examples with sudo (always works) and add a note explaining when the installer-granted adm group lets you drop sudo. Refs #2304 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs: document one-time cleanup of pre-existing json-file logs Address Copilot review on #2853: the journald switch only affects future writes, so devices upgrading from the old json-file driver still have the historical *-json.log files on disk and need to reclaim that space manually. Add a note + a safe truncate command (deleting while docker has the file open is unsafe; truncate -s 0 zeroes them in place). Refs #2304 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 8cc7411 commit 789d214

3 files changed

Lines changed: 74 additions & 3 deletions

File tree

bin/enable_ssl.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ EOF
201201
cat <<'EOF'
202202
- anthias-caddy-data:/data
203203
- anthias-caddy-config:/config
204+
logging:
205+
driver: journald
206+
options:
207+
tag: anthias-caddy
204208
205209
volumes:
206210
anthias-caddy-data:

docker-compose.yml.tmpl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ services:
2929
- /etc/localtime:/etc/localtime:ro
3030
labels:
3131
io.balena.features.supervisor-api: '1'
32+
logging:
33+
driver: journald
34+
options:
35+
tag: anthias-server
3236

3337
anthias-viewer:
3438
image: ghcr.io/screenly/anthias-viewer:${DOCKER_TAG}-${DEVICE_TYPE}
@@ -55,6 +59,10 @@ services:
5559
- /etc/localtime:/etc/localtime:ro
5660
labels:
5761
io.balena.features.supervisor-api: '1'
62+
logging:
63+
driver: journald
64+
options:
65+
tag: anthias-viewer
5866

5967
anthias-celery:
6068
# Runs on the same image as anthias-server with a CMD override.
@@ -94,6 +102,10 @@ services:
94102
- /etc/localtime:/etc/localtime:ro
95103
labels:
96104
io.balena.features.supervisor-api: '1'
105+
logging:
106+
driver: journald
107+
options:
108+
tag: anthias-celery
97109

98110
redis:
99111
image: ghcr.io/screenly/anthias-redis:${DOCKER_TAG}-${DEVICE_TYPE}
@@ -105,6 +117,10 @@ services:
105117
restart: always
106118
volumes:
107119
- redis-data:/var/lib/redis
120+
logging:
121+
driver: journald
122+
options:
123+
tag: anthias-redis
108124

109125
volumes:
110126
resin-data:

website/content/docs/_index.md

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,27 @@ and `raspberrypi` for the hostname, then run:
1212
$ ssh pi@raspberrypi
1313
```
1414

15-
Anthias makes use of Docker for containerization. To get the logs from the
16-
containers, you can either make use of the `docker logs` command or you can
17-
use the `docker compose logs` command.
15+
Anthias ships its container logs through the host's `systemd-journald`,
16+
so the system handles rotation and retention for you. The four core
17+
services (`anthias-server`, `anthias-viewer`, `anthias-celery`, `redis`)
18+
plus the optional `anthias-caddy` TLS sidecar all use the journald
19+
driver, so they don't write the unbounded `*-json.log` files under
20+
`/var/lib/docker/containers/` that can fill an SD card on long-running
21+
installs. You can read the logs three ways: `docker logs`,
22+
`docker compose logs`, or `journalctl` directly.
23+
24+
> **Note**
25+
>
26+
> Switching the driver only affects future writes. Devices that were
27+
> on the old `json-file` driver will still have the existing log files
28+
> on disk after upgrading. To reclaim that space, truncate the leftover
29+
> files in place (Docker keeps them open, so deleting can confuse the
30+
> daemon — `truncate -s 0` is safe):
31+
>
32+
> ```bash
33+
> $ sudo find /var/lib/docker/containers/ -name "*-json.log" \
34+
> -exec truncate -s 0 {} +
35+
> ```
1836
1937
### Using `docker logs`
2038
@@ -59,6 +77,39 @@ $ docker compose logs -f ${SERVICE_NAME}
5977
6078
Check out [this section](/docs/development/#understanding-the-components-that-make-up-anthias) of the Developer documentation page for the list of available services.
6179
80+
### Using `journalctl`
81+
82+
Each service is tagged in the journal so you can pull logs without
83+
docker. Useful when you want to grep across a long time range or
84+
combine container logs with system logs:
85+
86+
```bash
87+
$ sudo journalctl -f CONTAINER_TAG=anthias-server
88+
$ sudo journalctl --since "1 hour ago" CONTAINER_TAG=anthias-viewer
89+
```
90+
91+
The available tags are `anthias-server`, `anthias-viewer`,
92+
`anthias-celery`, `anthias-redis`, and (when TLS is enabled)
93+
`anthias-caddy`.
94+
95+
> **Note**
96+
>
97+
> The Anthias installer adds your user to the `adm` group, which on
98+
> Debian/Raspberry Pi OS grants read access to the journal once you've
99+
> logged out and back in (and provided the journal is persistent —
100+
> i.e. `/var/log/journal/` exists). On systems where that's set up you
101+
> can drop the `sudo` from the commands above.
102+
103+
Journal retention is controlled by `systemd-journald` (see
104+
`/etc/systemd/journald.conf` — `SystemMaxUse` caps total disk usage,
105+
defaulting to 10% of the filesystem). If you want to free space
106+
immediately:
107+
108+
```bash
109+
$ sudo journalctl --vacuum-time=2d # drop entries older than 2 days
110+
$ sudo journalctl --vacuum-size=200M # cap journal at 200 MB
111+
```
112+
62113
## Enabling SSH
63114
64115
See [the official documentation](https://www.raspberrypi.org/documentation/remote-access/ssh/)

0 commit comments

Comments
 (0)