How do I change I change my redis docker containers password?

31 views Asked by At

so I recently setup my bitnami/redis server using docker-compose, but the issue I am currently facing is how do I change the password for the container?

What I have tried doing is copying the redis configuration from docker container into my current working directory and then modifying it and placing it back in. However, after restarting the docker container, the changes were not consistent and changed back to its original state.

docker cp 5fb8fc71bcaf:/opt/bitnami/redis/etc/redis.conf .
docker cp . 5fb8fc71bcaf:/opt/bitnami/redis/etc/redis.conf

My docker-compose file consists of the following

version: "3.9"

services:
    redis:
        image: 'bitnami/redis:latest'
        environment:
            - REDIS_PASSWORD=yourpassword
        restart: always
        ports:
            - 6379:6379
        volumes:
            - redis-core-data:/bitnami/redis/data
        
volumes:
    redis-core-data:
        driver: local

I would appreciate any help :)

1

There are 1 answers

0
datawookie On

That configuration should work fine, although I'd suggest choosing a more secure password.

version: "3.9"

services:
    redis:
        image: 'bitnami/redis:7.2.4'
        container_name: 'redis'
        environment:
            - REDIS_PASSWORD=4iauxFqoQPqCwA%G
        restart: always
        ports:
            - 6379:6379
        volumes:
            - redis-core-data:/bitnami/redis/data
        
volumes:
    redis-core-data:
        driver: local

In the screenshot below you can see in the top panel the Docker Compose configuration above running. In the bottom panel three attempts to interact with Redis:

  1. Connect without password. Connection is "successful" but you can't interact with Redis. ❌
  2. Connect with wrong password. Connection is "successful" but there's an error message and you can't interact with Redis. ❌
  3. Connect with correct password. Connection is actually successful and you can interact with Redis. ✅

enter image description here