Persistent storage using the default settings doesn't survive 'docker compose down'
I was trying to track down why my stream ID's were changing.
The provided docker compose files attempt persistent storage by using volumes (top level), and mounting graylog files within. The volumes however are not persistent and are remade after a docker compose down and up.
Does this mean the entire database is re-created every time?
Does this mean the entire database is re-created every time?
I'll have to double-check the database entries. Interestingly when I do a docker compose down && up I'm seeing the inputs preserved, but the node_id isn't preserved, so all my inputs that had a local node set are all disabled until I specifiy a new node. I seem to remember from playing with Postgres that even though it's dockerised it's still using the host filesystem for storage - perhaps mariadb does the same, making it immune to container deletion?
The data is persisted by default (with the volume mount defined in the mongodb service), but the node-id is not (by default).
In the docker-compose.yml, the environment variable GRAYLOG_NODE_ID_FILE specifies the filepath for the node-id to be /usr/share/graylog/data/config/node-id, which is not mounted as a volume from the host. As such, any time the Graylog container is recreated, the node-id will be regenerated.
Simply add
services:
graylog:
[...]
volumes:
# Persist the graylog config
- "graylog_cfg:/usr/share/graylog/data/config"
volumes:
[...]
# Define the volume
graylog_cfg:
to ensure that the node-id is consistent across restarts.
It looks to me that this is the same issue as this: https://github.com/Graylog2/docker-compose/issues/27 Default Volumes in docker-compose.yml looks like this
volumes:
- "graylog_data:/usr/share/graylog/data/data"
- "graylog_journal:/usr/share/graylog/data/journal"
graylog_data should point to /usr/share/graylog/data. Also graylog_journal should point to an own path, eg. /usr/share/graylog/journal, and in graylog.conf
message_journal_dir=journal