Repository navigation
Description
In the Docker Compose deployment, clamd can never start. Two separate permission problems are each independently fatal, and neither is surfaced to the operator — every health indicator reports the scanner as running while nothing is being scanned.
1. Signature directory is not writable by clamd's uid
The bind-mounted signature directory is root-owned on the host, but clamd runs as uid 102 inside the container, so freshclam can never write:
ERROR: Can't create temporary directory /var/lib/clamav/tmp.<random>
Hint: The database directory must be writable for UID 102 or GID 106
ERROR: Update failed.
2. clamd cannot create its socket directory
With signatures fixed, clamd still cannot start, because it tries to create its socket directory under root-owned /var/run:
ERROR: LOCAL: Could not create socket directory: /var/run/clamav: Permission denied
ERROR: LOCAL: Socket file /var/run/clamav/clamd.ctl could not be bound: No such file or directory
This loops indefinitely. Meanwhile supervisorctl status reports clamav-daemon RUNNING and ps shows the process alive, so both of the obvious checks say the service is healthy.
Impact
This is the part that matters most. Mail continues to flow. Amavis logs:
(!!)AV: ALL VIRUS SCANNERS FAILED
... Passed UNCHECKED ...
but the delivered message still carries an X-Virus-Scanned: Debian amavis header. An operator inspecting the deployment has every reason to believe virus scanning is active — supervisor says RUNNING, the process exists, and delivered mail is stamped as scanned — while in fact nothing is being scanned.
Also worth noting: /var/run is tmpfs, so even a manual fix inside the container is lost on every container restart.
Expected behaviour
- clamd should start successfully in the Docker deployment without manual intervention.
- If clamd has no working socket, that should be reported as a failure, and mail should not be stamped
X-Virus-Scanned.
Reproduction
- Install with
openship up --compose(openship CLI 0.6.5,openship-mail:0.6.5), single box. - Deploy the mail engine from the Emails UI.
docker logs openship-mail— freshclam update failures, then the socket directory failure looping.supervisorctl statusinside the container —clamav-daemon RUNNING.- Send a message through and inspect the delivered headers —
X-Virus-Scanned: Debian amavispresent despiteALL VIRUS SCANNERS FAILEDin the amavis log.
Workarounds used
chown -R 102:106on the host's bind-mounted clamav directory.- Creating
/var/run/clamavowned byclamavinside the container on every container start, driven from a host-side systemd unit watchingdocker events(needed because/var/runis tmpfs).
After both, clamdscan correctly returns Eicar-Test-Signature FOUND.
Suggested fix
- Create
/var/run/clamavwith the correct ownership in the image entrypoint or in the supervisord program config, so it survives the tmpfs reset on every restart. - Set ownership on the bind-mounted signature directory at container startup to match the uid/gid clamd runs as.
- Do not report
clamav-daemon RUNNING, and do not add theX-Virus-Scannedheader, when clamd has no working socket. A silent failure here is worse than a loud one.
Environment
- Ubuntu 22.04, single box
- Installed via
openship up --compose, openship CLI 0.6.5 openship-mail:0.6.5, host control enabled- Mail engine deployed through the Emails UI
Activity
Hydralerne commentedon Aug 15, 2026
fixed