Skip to content

Repository files navigation

OSSEC Docker

Docker image for the OSSEC HIDS manager (server). Rocky Linux 10, OSSEC 4.5.0 from the Atomicorp ossec-hids-server RPM.

Image: atomicorp/ossec-docker
Source: https://github.com/ossec/ossec-docker

Quick start

docker volume create ossec-data

docker run -d \
  --name ossec-server \
  -p 1514:1514/udp \
  -p 1515:1515/tcp \
  -v ossec-data:/var/ossec/data \
  atomicorp/ossec-docker

Or:

docker compose up -d
docker exec -it ossec-server /var/ossec/bin/ossec-control status
docker exec -it ossec-server tail -f /var/ossec/logs/ossec.log
Port Protocol Purpose
1514 UDP Agent events (ossec-remoted)
1515 TCP Agent enrollment (ossec-authd)

Persistent data lives on the volume at /var/ossec/data (etc, logs, stats, queue).

Add agents

Point agents at the manager host on UDP/1514. Enrollment is on by default via authd (TCP/1515). Inside the container you can also manage keys manually:

docker exec -it ossec-server /var/ossec/bin/manage_agents

Disable authd if you only want pre-shared keys:

docker run -d \
  --name ossec-server \
  -p 1514:1514/udp \
  -e AUTO_ENROLLMENT_ENABLED=false \
  -v ossec-data:/var/ossec/data \
  atomicorp/ossec-docker
Variable Default Meaning
AUTO_ENROLLMENT_ENABLED true Start ossec-authd on port 1515
AUTHD_OPTIONS (empty) Extra arguments for ossec-authd

Custom configuration

Mount ossec.conf onto the data volume path (not /var/ossec/etc, which is a symlink). The entrypoint fills in any missing files under etc/ (rules.d, decoders.d, internal_options.conf, …) and leaves your config alone:

docker run -d \
  --name ossec-server \
  -p 1514:1514/udp \
  -p 1515:1515/tcp \
  -v ossec-data:/var/ossec/data \
  -v "$PWD/ossec.conf:/var/ossec/data/etc/ossec.conf:ro" \
  atomicorp/ossec-docker

Rules and decoders

The image ships the ossec/ossec-rules community CRS bundle (v4.0 by default) into:

  • /var/ossec/data/etc/rules.d
  • /var/ossec/data/etc/decoders.d
  • /var/ossec/data/etc/shared (rootcheck / CIS lists)

Drop site rules as extra .xml files under rules.d (use a 99- prefix so they load after the CRS pack) and restart. Pin another rules release at build time with --build-arg OSSEC_RULES_VERSION=v4.0.

Day-to-day

docker stop ossec-server
docker start ossec-server
docker exec -it ossec-server bash
Path Contents
/var/ossec/data/etc ossec.conf, keys, SSL certs, rules.d, decoders.d
/var/ossec/data/logs ossec.log, alerts, archives
/var/ossec/data/stats Analysisd statistics
/var/ossec/data/queue Runtime queues (including FIM queue/diff)

Alert mail goes through a local Postfix in the container. Point <smtp_server> in ossec.conf at a real MTA if you need delivery outside the container.

Build

docker build \
  --build-arg OSSEC_VERSION=4.5.0 \
  --build-arg OSSEC_RULES_VERSION=v4.0 \
  -t ossec-docker:local .
Argument Default Meaning
OSSEC_VERSION 4.5.0 ossec-hids-server RPM version
OSSEC_RULES_VERSION v4.0 ossec-rules git tag

Troubleshooting

Symptom Fix
Missing decoder.xml / rules fail after mounting a config Mount at /var/ossec/data/etc/ossec.conf; use a current image so etc/ is seeded
queue/diff / report_changes errors Current image resets queue/diff to root:ossec mode 1770 on start
ossec-authd: SSL Error Usually a client/probe handshake issue; check agent-auth usage
No alert mail Configure an external <smtp_server> or disable mail notifications

Links

Thanks to Dan Parriott and Xetus OSS for the original container design.