'Prometheus alertmanager persistent storage with docker

For some reason I can't get persistent storage to work with alertmanager. This is my compose:

  alertmanager:
    image: 'my/alertmanager/prod:latest'
    restart: always
    volumes:
      - alertmanager-data:/alertmanager-data
    command:
      - '--config.file=/alertmanager/alertmanager-config.yml'
      - '--storage.path=/alertmanager-data'
    ports:
      - 9103:9093

  volumes:
    alertmanager-data:
      external: true

I have created the volume and everything seems to initialise correctly. But after entering the machine /alertmanager-data doesn't seem to contain any DB or files. And creating new silences on the alertmanager never persist.



Solution 1:[1]

Moved from comment for visibility

It turns out that it actually does work, but it takes a while for it to write memory to storage. I don't remember how often it is stored but it takes some time.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1