# Are snapshots working using Docker compose?

**URL:** <https://dragonfly.discourse.group/t/are-snapshots-working-using-docker-compose/290>\
**Category:** Kubernetes\
**Created:** [June 25, 2025, 3:05pm UTC](https://dragonfly.discourse.group/t/are-snapshots-working-using-docker-compose/290 "2025-06-25T15:05:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![windmeup](https://avatars.discourse-cdn.com/v4/letter/w/779978/32.png) [@windmeup](https://dragonfly.discourse.group/u/windmeup)\
**Post date:** [June 25, 2025, 3:05pm UTC](https://dragonfly.discourse.group/t/are-snapshots-working-using-docker-compose/290/1 "2025-06-25T15:05:35Z")

</div>

I’ve been running Dragonflydb on a single node using Docker compose for about 8 months now. I am using the following docker compose yaml to attempt to take snapshots every 5 minutes:

```auto
# This version persists data.
services:
  dragonfly:
    image: 'docker.dragonflydb.io/dragonflydb/dragonfly'
    command: ["dragonfly", "--logtostderr", "--dir", "/data", "--snapshot_cron", "*/5 * * * *"] # Example cron schedule for every 5 minutes
    # Then you will also have to have a cron job to delete old snapshots
    ulimits:
      memlock: -1
    restart: unless-stopped
    #ports:
    # - "6379:6379"
    # For better performance, consider `host` mode instead `port` to avoid dock>
    # `host` mode is NOT currently supported in Swarm Mode.
    # https://docs.docker.com/compose/compose-file/compose-file-v3/#network_mode
    network_mode: "host"
    volumes:
       - dragonflydata:/data
volumes:
  dragonflydata:

```

This code runs the db fine, but when I look at

> /var/lib/docker/volumes/redis\_dragonflydata/\_data

Timestamps are created when I first start the container but never updated afterwards. If the snapshot files are getting updated then I would expect the filesystem timestamps to change.

Either something’s not working or I have some incorrect assumptions.

Thanks for any help.

---

<div class="post-metadata">

**Author:** ![joezhou\_df](https://yyz2.discourse-cdn.com/flex004/user_avatar/dragonfly.discourse.group/joezhou_df/32/82_2.png) [@joezhou\_df](https://dragonfly.discourse.group/u/joezhou_df)\
**Post date:** [June 25, 2025, 8:21pm UTC](https://dragonfly.discourse.group/t/are-snapshots-working-using-docker-compose/290/2 "2025-06-25T20:21:50Z")

</div>

Hi @windmeup, good question!

I think the gist is that you don’t pass `dragonfly` as the first argument. I tested it myself, and all the following 3 ways could work.

### Command as a Whole String

```yaml
services:
  dragonfly:
    image: "docker.dragonflydb.io/dragonflydb/dragonfly"
    command: "--proactor_threads 2 --snapshot_cron '*/5 * * * *'"
    ulimits:
      memlock: -1
    ports:
      - "6379:6379"
    restart: unless-stopped
    volumes:
      - dragonflydata:/data
volumes:
  dragonflydata:

```

### Command as a YAML List

```yaml
services:
  dragonfly:
    image: "docker.dragonflydb.io/dragonflydb/dragonfly"
    command:
      - "--proactor_threads"
      - "2"
      - "--snapshot_cron"
      - "*/5 * * * *"
    ulimits:
      memlock: -1
    ports:
      - "6379:6379"
    restart: unless-stopped
    volumes:
      - dragonflydata:/data
volumes:
  dragonflydata:

```

### Command as a Compact List

This is probably the way you prefer:

```yaml
services:
  dragonfly:
    image: "docker.dragonflydb.io/dragonflydb/dragonfly"
    command: ["--proactor_threads", "2", "--snapshot_cron", "*/5 * * * *"]
    ulimits:
      memlock: -1
    ports:
      - "6379:6379"
    restart: unless-stopped
    volumes:
      - dragonflydata:/data
volumes:
  dragonflydata:

```

* * *

After Dragonfly is booted, you can connect and verify the `snapshot_cron` configuration like below:

```shell
$> redis-cli # Note that I have the port accessible locally.

dragonfly$> CONFIG GET snapshot_cron
1) "snapshot_cron"
2) "*/5 * * * *"

```

I also monitored, seeing that snapshots are created based on the cron schedule:

 ![image](https://canada1.discourse-cdn.com/flex004/uploads/dragonfly/original/1X/fa636e6e5b9e71032d18b9757db8e43f7a7da1f3.jpeg)

* * *

Thanks for the question. I will update the documentation with examples like this shortly.

---

<div class="post-metadata">

**Author:** ![windmeup](https://avatars.discourse-cdn.com/v4/letter/w/779978/32.png) [@windmeup](https://dragonfly.discourse.group/u/windmeup)\
**Post date:** [June 26, 2025, 12:25pm UTC](https://dragonfly.discourse.group/t/are-snapshots-working-using-docker-compose/290/3 "2025-06-26T12:25:29Z")

</div>

You are a prince! 😉

Thank you!

---

<div class="post-metadata">

**Author:** ![windmeup](https://avatars.discourse-cdn.com/v4/letter/w/779978/32.png) [@windmeup](https://dragonfly.discourse.group/u/windmeup)\
**Post date:** [June 26, 2025, 1:43pm UTC](https://dragonfly.discourse.group/t/are-snapshots-working-using-docker-compose/290/4 "2025-06-26T13:43:26Z")

</div>

Question; does that mean that I no longer need these?"

“–logtostderr”, “–dir”, “/data”,

---

<div class="post-metadata">

**Author:** ![joezhou\_df](https://yyz2.discourse-cdn.com/flex004/user_avatar/dragonfly.discourse.group/joezhou_df/32/82_2.png) [@joezhou\_df](https://dragonfly.discourse.group/u/joezhou_df)\
**Post date:** [June 26, 2025, 6:08pm UTC](https://dragonfly.discourse.group/t/are-snapshots-working-using-docker-compose/290/6 "2025-06-26T18:08:03Z")

</div>

You can still pass additional server flags as needed!

I was using `"--proactor_threads", "2", "--snapshot_cron", "*/5 * * * *"` earlier just as an example, as I was running it locally too and wanted to have a smaller memory requirement and test the flags.

---

<div class="post-metadata">

**Author:** ![windmeup](https://avatars.discourse-cdn.com/v4/letter/w/779978/32.png) [@windmeup](https://dragonfly.discourse.group/u/windmeup)\
**Post date:** [June 26, 2025, 7:34pm UTC](https://dragonfly.discourse.group/t/are-snapshots-working-using-docker-compose/290/7 "2025-06-26T19:34:50Z")

</div>

I did pass some more and it’s working great. I also wrote a script to be run on cron every 15 minutes to leave just the last 4 days of logs.
