DEV Community

Cover image for Redis container and persisting
Visakh Vijayan
Visakh Vijayan

Posted on • Edited on

15 1

Redis container and persisting

Spent quite some time trying to persist data of redis container to the host machine. Here is how to do it finally -

redis_db:
        container_name: redis_db
        command: bash -c "redis-server --appendonly yes --requirepass <password>"
        image: redis
        ports:
            - "6379:6379"
        volumes:
            - ./redis-volume:/data
Enter fullscreen mode Exit fullscreen mode

Here I have mapped the host's redis-volume folder with the /data folder of the redis container. Once done you will be able to find files called appendonly.aof and dump.rdb inside it. You will be able to see these files inside your container at /data as well. To see that use

> docker ps
> docker exec -it <containerId> bash
# cd /data
Enter fullscreen mode Exit fullscreen mode

When you start your container up, you will find a line like so -

redis_db | 1:M 08 Jun 2020 19:58:58.987 * DB loaded from append only file: 0.000 seconds

Also, change the persmissions of the host folder to a writable one.

Hope this helps someone! :D

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (2)

Collapse
 
softjake profile image
Jacques • Edited

Sure did help, thanks.

Collapse
 
uponthesky profile image
UponTheSky

This is what I was looking for. Thanks!

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up