How do you write a docker compose file so that it recognizes a Redis config file and a custom username/password (I am trying to use an ACL file, see below) that is not hardcoded into the Redis-stack-service. My setup at first looks like everything is working from the docker side of things, but when I try to log into Insight or run some python code, it gives errors that make it apparent it only has the default user with no password. I haven't found a Docker compose example that works, despite finding several that claim to. Using docker run redis-stack and explicitly including a --requirepass appears to work, but I will eventually be converting it to a swarm service to integrate with Traefik, and this makes using docker run as an option not feasible. Using a password directly in a command is not really a good safety procedure either.
Here is an example compose file:
services: redis: image: "redis/redis-stack:latest" container_name: "redis-with-volumes" ports: - "6379:6379" - "8001:8001" networks: - redis-net volumes: - /data:/data - /config/redis.conf:/redis.conf - /config/redis-acl.conf:/redis-acl.conf command: redis-stack --appendonly yes --bind redis-with-volumes --appendfilename appendonly.aof --protected-mode no --aclfile /usr/local/etc/redis/config/redis-acl.conf --include /usr/local/etc/redis/config/redis.conf environment: - NICEGUI_REDIS_URL=redis://redis-stack:6379 - PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin restart: unless-stopped volumes: redis-data: redis-conf: redid-acl: networks: redis-net: driver: bridge Here is the config I am trying to use:
# Redis configuration file include redis.conf loadmodule ./modules/redisbloom/redisbloom.so loadmodule ./modules/redisearch/redisearch.so loadmodule ./modules/redisjson/rejson.so loadmodule ./modules/redistimeseries/redistimeseries.so # Basic configuration port 6379 bind 0.0.0.0 # Persistence dir /data appendonly yes appendfilename "appendonly.aof" # Security protected-mode no aclfile /var/lib/redis-stack/redis-acl.conf maxRetriesPerRequest 1000 Here is my redis-acl.config file (passwords removed, obviously):
user default off +@all ~* &* >[password] user admin on +@all ~* &* >[password] user restricted on +@read +@write -@dangerous ~* &* >[password] The docker output makes it seem like everything is fine:
docker compose up [+] Running 2/2 ✔ Network redis_redis-net Created 0.0s ✔ Container redis-with-volumes Created 0.0s Attaching to redis-with-volumes redis-with-volumes | Starting redis-stack-server, database path /var/lib/redis-stack redis-with-volumes | 14:C 05 Nov 2025 03:22:08.168 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo redis-with-volumes | 14:C 05 Nov 2025 03:22:08.168 * Redis version=7.4.6, bits=64, commit=00000000, modified=0, pid=14, just started redis-with-volumes | 14:C 05 Nov 2025 03:22:08.168 * Configuration loaded redis-with-volumes | 14:M 05 Nov 2025 03:22:08.169 * monotonic clock: POSIX clock_gettime redis-with-volumes | 14:M 05 Nov 2025 03:22:08.171 * Running mode=standalone, port=6379. redis-with-volumes | 14:M 05 Nov 2025 03:22:08.171 * Module 'RedisCompat' loaded from /opt/redis-stack/lib/rediscompat.so redis-with-volumes | 14:M 05 Nov 2025 03:22:08.172 * <search> Redis version found by RedisSearch : 7.4.6 - oss redis-with-volumes | 14:M 05 Nov 2025 03:22:08.172 * <search> RediSearch version 2.10.20 (Git=5c09b69) redis-with-volumes | 14:M 05 Nov 2025 03:22:08.172 * <search> Low level api version 1 initialized successfully redis-with-volumes | 14:M 05 Nov 2025 03:22:08.172 * <search> gc: ON, prefix min length: 2, min word length to stem: 4, prefix max expansions: 200, query timeout (ms): 500, timeout policy: return, cursor read size: 1000, cursor max idle (ms): 300000, max doctable size: 1000000, max number of search results: 10000, redis-with-volumes | 14:M 05 Nov 2025 03:22:08.172 * <search> Initialized thread pools! redis-with-volumes | 14:M 05 Nov 2025 03:22:08.172 * <search> Subscribe to config changes redis-with-volumes | 14:M 05 Nov 2025 03:22:08.172 * <search> Enabled role change notification redis-with-volumes | 14:M 05 Nov 2025 03:22:08.172 * Module 'search' loaded from /opt/redis-stack/lib/redisearch.so redis-with-volumes | 14:M 05 Nov 2025 03:22:08.173 * <timeseries> RedisTimeSeries version 11206, git_sha=cdcbe34f8e87e15ea700b737634be6bac6b6700b redis-with-volumes | 14:M 05 Nov 2025 03:22:08.173 * <timeseries> Redis version found by RedisTimeSeries : 7.4.6 - oss redis-with-volumes | 14:M 05 Nov 2025 03:22:08.173 * <timeseries> loaded default CHUNK_SIZE_BYTES policy: 4096 redis-with-volumes | 14:M 05 Nov 2025 03:22:08.173 * <timeseries> loaded server DUPLICATE_POLICY: block redis-with-volumes | 14:M 05 Nov 2025 03:22:08.173 * <timeseries> loaded default IGNORE_MAX_TIME_DIFF: 0 redis-with-volumes | 14:M 05 Nov 2025 03:22:08.173 * <timeseries> loaded default IGNORE_MAX_VAL_DIFF: 0.000000 redis-with-volumes | 14:M 05 Nov 2025 03:22:08.173 * <timeseries> Setting default series ENCODING to: compressed redis-with-volumes | 14:M 05 Nov 2025 03:22:08.173 * <timeseries> Detected redis oss redis-with-volumes | 14:M 05 Nov 2025 03:22:08.173 * Module 'timeseries' loaded from /opt/redis-stack/lib/redistimeseries.so redis-with-volumes | 14:M 05 Nov 2025 03:22:08.174 * <ReJSON> Created new data type 'ReJSON-RL' redis-with-volumes | 14:M 05 Nov 2025 03:22:08.174 # <ReJSON> Skip register defrag callbacks as defrag callbacks is not supported on the current Redis server. redis-with-volumes | 14:M 05 Nov 2025 03:22:08.174 * <ReJSON> version: 20809 git sha: unknown branch: unknown redis-with-volumes | 14:M 05 Nov 2025 03:22:08.174 * <ReJSON> Exported RedisJSON_V1 API redis-with-volumes | 14:M 05 Nov 2025 03:22:08.174 * <ReJSON> Exported RedisJSON_V2 API redis-with-volumes | 14:M 05 Nov 2025 03:22:08.174 * <ReJSON> Exported RedisJSON_V3 API redis-with-volumes | 14:M 05 Nov 2025 03:22:08.174 * <ReJSON> Exported RedisJSON_V4 API redis-with-volumes | 14:M 05 Nov 2025 03:22:08.174 * <ReJSON> Exported RedisJSON_V5 API redis-with-volumes | 14:M 05 Nov 2025 03:22:08.174 * <ReJSON> Enabled diskless replication redis-with-volumes | 14:M 05 Nov 2025 03:22:08.174 * <ReJSON> Initialized shared string cache, thread safe: false. redis-with-volumes | 14:M 05 Nov 2025 03:22:08.174 * Module 'ReJSON' loaded from /opt/redis-stack/lib/rejson.so redis-with-volumes | 14:M 05 Nov 2025 03:22:08.174 * <search> Acquired RedisJSON_V5 API redis-with-volumes | 14:M 05 Nov 2025 03:22:08.174 * <bf> RedisBloom version 2.8.7 (Git=unknown) redis-with-volumes | 14:M 05 Nov 2025 03:22:08.174 * Module 'bf' loaded from /opt/redis-stack/lib/redisbloom.so redis-with-volumes | 14:M 05 Nov 2025 03:22:08.174 * <redisgears_2> Created new data type 'GearsType' redis-with-volumes | 14:M 05 Nov 2025 03:22:08.174 * <redisgears_2> Detected redis oss redis-with-volumes | 14:M 05 Nov 2025 03:22:08.175 # <redisgears_2> could not initialize RedisAI_InitError redis-with-volumes | redis-with-volumes | 14:M 05 Nov 2025 03:22:08.175 * <redisgears_2> Failed loading RedisAI API. redis-with-volumes | 14:M 05 Nov 2025 03:22:08.175 * <redisgears_2> RedisGears v2.0.20, sha='9b737886bf825fe29ddc2f8da81f73cbe0b4e858', build_type='release', built_for='Linux-ubuntu22.04.x86_64', redis_version:'7.4.6', enterprise:'false'. redis-with-volumes | 14:M 05 Nov 2025 03:22:08.175 * <redisgears_2> Registered backend: js. redis-with-volumes | 14:M 05 Nov 2025 03:22:08.176 * Module 'redisgears_2' loaded from /opt/redis-stack/lib/redisgears.so redis-with-volumes | 14:M 05 Nov 2025 03:22:08.177 * Server initialized redis-with-volumes | 14:M 05 Nov 2025 03:22:08.181 * Creating AOF base file appendonly.aof.1.base.rdb on server start redis-with-volumes | 14:M 05 Nov 2025 03:22:08.192 * Creating AOF incr file appendonly.aof.1.incr.aof on server start redis-with-volumes | 14:M 05 Nov 2025 03:22:08.192 * Ready to accept connections tcp But when I try to log in to the database in Redis Insight, the only thing that works is a default username with no password:

and if I try to run some python code using the Redis API, for ex.: app.storage.redis= redis.Redis(host="localhost",username='admin',password=os.getenv('redis_password'), port=6379, decode_responses=True) it complains, saying there is no password:
python home.py -v Could not load data from Redis with key otherus:general NiceGUI ready to go on http://localhost:8080 AUTH <password> called without any password configured for the default user. Are you sure your configuration is correct? Traceback (most recent call last): File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\nicegui\background_tasks.py", line 93, in _handle_exceptions task.result() ~~~~~~~~~~~^^ File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\nicegui\persistence\redis_persistent_dict.py", line 81, in backup if not await self.redis_client.exists(self.key) and not self: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\asyncio\client.py", line 720, in execute_command conn = self.connection or await pool.get_connection() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\asyncio\connection.py", line 1198, in get_connection await self.ensure_connection(connection) File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\asyncio\connection.py", line 1231, in ensure_connection await connection.connect() File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\asyncio\connection.py", line 298, in connect await self.connect_check_health(check_health=True) File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\asyncio\connection.py", line 324, in connect_check_health await self.on_connect_check_health(check_health=check_health) File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\asyncio\connection.py", line 410, in on_connect_check_health auth_response = await self.read_response() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\asyncio\connection.py", line 607, in read_response response = await self._parser.read_response( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ disable_decoding=disable_decoding ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\_parsers\resp2.py", line 82, in read_response response = await self._read_response(disable_decoding=disable_decoding) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\_parsers\resp2.py", line 102, in _read_response raise error redis.exceptions.AuthenticationError: AUTH <password> called without any password configured for the default user. Are you sure your configuration is correct? AUTH <password> called without any password configured for the default user. Are you sure your configuration is correct? Traceback (most recent call last): File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\nicegui\background_tasks.py", line 93, in _handle_exceptions task.result() ~~~~~~~~~~~^^ File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\nicegui\persistence\redis_persistent_dict.py", line 81, in backup if not await self.redis_client.exists(self.key) and not self: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\asyncio\client.py", line 720, in execute_command conn = self.connection or await pool.get_connection() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\asyncio\connection.py", line 1198, in get_connection await self.ensure_connection(connection) File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\asyncio\connection.py", line 1231, in ensure_connection await connection.connect() File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\asyncio\connection.py", line 298, in connect await self.connect_check_health(check_health=True) File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\asyncio\connection.py", line 324, in connect_check_health await self.on_connect_check_health(check_health=check_health) File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\asyncio\connection.py", line 410, in on_connect_check_health auth_response = await self.read_response() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\asyncio\connection.py", line 607, in read_response response = await self._parser.read_response( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ disable_decoding=disable_decoding ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\_parsers\resp2.py", line 82, in read_response response = await self._read_response(disable_decoding=disable_decoding) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\_parsers\resp2.py", line 102, in _read_response raise error redis.exceptions.AuthenticationError: AUTH <password> called without any password configured for the default user. Are you sure your configuration is correct? Could not load data from Redis with key otherus:user-93961558-e87f-40f2-babb-f7ac8de69655 AUTH <password> called without any password configured for the default user. Are you sure your configuration is correct? Traceback (most recent call last): File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\nicegui\background_tasks.py", line 93, in _handle_exceptions task.result() ~~~~~~~~~~~^^ File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\nicegui\persistence\redis_persistent_dict.py", line 81, in backup if not await self.redis_client.exists(self.key) and not self: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\asyncio\client.py", line 720, in execute_command conn = self.connection or await pool.get_connection() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\asyncio\connection.py", line 1198, in get_connection await self.ensure_connection(connection) File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\asyncio\connection.py", line 1231, in ensure_connection await connection.connect() File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\asyncio\connection.py", line 298, in connect await self.connect_check_health(check_health=True) File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\asyncio\connection.py", line 324, in connect_check_health await self.on_connect_check_health(check_health=check_health) File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\asyncio\connection.py", line 410, in on_connect_check_health auth_response = await self.read_response() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\asyncio\connection.py", line 607, in read_response response = await self._parser.read_response( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ disable_decoding=disable_decoding ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\_parsers\resp2.py", line 82, in read_response response = await self._read_response(disable_decoding=disable_decoding) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Someone\micromamba\envs\otherus\Lib\site-packages\redis\_parsers\resp2.py", line 102, in _read_response raise error redis.exceptions.AuthenticationError: AUTH <password> called without any password configured for the default user. Are you sure your configuration is correct? home False http://localhost:8080/ Could not load data from Redis with key