docker-compose icon indicating copy to clipboard operation
docker-compose copied to clipboard

Persistent storage using the default settings doesn't survive 'docker compose down'

Open dreaded369 opened this issue 2 years ago • 4 comments

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.

dreaded369 avatar Jul 16 '23 03:07 dreaded369

Does this mean the entire database is re-created every time?

kroepke avatar Jul 17 '23 14:07 kroepke

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?

dreaded369 avatar Jul 17 '23 14:07 dreaded369

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.

netr0m avatar Jul 18 '23 16:07 netr0m

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

hertell avatar Oct 29 '23 16:10 hertell