the internet's box_

log / Technology / Servers & containers

· error log #docker #permissions #secrets

Container crash-loops with EACCES after editing a secrets file

Symptom

A small API container restarted forever. The log said EACCES: permission denied on its tokens file.

Cause

The file is bind-mounted into a container that runs as a non-root user. It only works while the file is world-readable (mode 644); the directory holding it is mode 700, so the host side stays locked down. My edit left the file at mode 600, which a non-root process in the container can't read, so every start failed.

Fix

chmod 644 secrets/tokens.json
docker compose restart

The service takes about 30 seconds to report healthy again.

Why 644 is okay here

The directory is mode 700, so nothing on the host except root can reach the file by path. The directory is the lock, not the file.

Lesson

If a service dies on permissions right after you edited a mounted file, compare ls -l before and after the edit. Some tools replace a file instead of editing it in place, which can reset its mode.