Skip to content

ClamAV cannot start in the Docker deployment and fails silently — mail passes unscanned but still gets an X-Virus-Scanned header #565

Closed

Description

@yashthakur1

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

  1. Install with openship up --compose (openship CLI 0.6.5, openship-mail:0.6.5), single box.
  2. Deploy the mail engine from the Emails UI.
  3. docker logs openship-mail — freshclam update failures, then the socket directory failure looping.
  4. supervisorctl status inside the container — clamav-daemon RUNNING.
  5. Send a message through and inspect the delivered headers — X-Virus-Scanned: Debian amavis present despite ALL VIRUS SCANNERS FAILED in the amavis log.

Workarounds used

  • chown -R 102:106 on the host's bind-mounted clamav directory.
  • Creating /var/run/clamav owned by clamav inside the container on every container start, driven from a host-side systemd unit watching docker events (needed because /var/run is tmpfs).

After both, clamdscan correctly returns Eicar-Test-Signature FOUND.

Suggested fix

  • Create /var/run/clamav with 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 the X-Virus-Scanned header, 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

  1. Hydralerne commented on Aug 15, 2026

    @Hydralerne
    Member

    fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions