I need to run a Docker container with Redis Stack pre-configured to use a config file and ACL file. My Dockerfile (placed in the same folder as the redis.conf
and users.acl
) is as follows:
FROM redis/redis-stack:latest
WORKDIR /db
COPY redis.conf ./redis-stack.conf
COPY users.acl ./users.acl
ENV PORT=6379
EXPOSE 6379
I run the container with docker run -p 6379:6379 --mount type=volume,source=database-vol,target=/db,readonly=0 container_name
, using a named volume.
After this, the Redis server starts, but instead of using these config/acl files, uses a default .conf
, seemingly placed in the /opt/redis-stack/etc
folder. Using COPY
in the Dockerfile to place my files in that folder instead doesn't help: the files are there, but the server doesn't use them: redis-cli
command acl list
returns the default user only, meaning my .conf
file is ignored.
I understand there is a possibility to pass arguments in docker run
with --env REDIS_ARGS=""
, but I am not sure if/which arguments would setup the configuration file.
How do I point the redis server in the container to use my files? Is it possible for them to be in an arbitrary location?
CodePudding user response:
Location of acl file is configured with aclfile parameter.
So, based on your Dockerfile, adding --env REDIS_ARGS="envfile /db/users.acl"
should do the trick.
Somehow related, pass arguments via the command line
CodePudding user response:
After some trying, figured it out. redis-stack-server
(or redis-server
if you're using the non-stack image) executable is already configured in PATH
, so it's possible to CMD
or RUN
it easily from the Dockerfile.
To run the server with the given config file, I use CMD [ "redis-stack-server", "redis.conf" ]
. The full Dockerfile is then as follows:
FROM redis/redis-stack:latest
WORKDIR /usr/local/db
COPY redis.conf ./redis.conf
COPY users.acl ./users.acl
ENV PORT=6379
EXPOSE 6379
CMD [ "redis-stack-server", "redis.conf" ]
This will start the Redis Stack server with the given configuration, as well users provided in the ACL file.