Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Yes, Docker secrets can be used to read the Redis password from /run/secrets/ and assign it to the Redis --requirepass parameter.

To do this, you can create a secret with the Redis password using the following command:

$ docker secret create redis-pass /path/to/redis-pass.txt

Next, you can pass the secret to the Redis service using the --secret flag when creating the service. For example:

$ docker service create \
  --name redis \
  --secret redis-pass \
  redis:latest \
  redis-server --requirepass $(cat /run/secrets/redis-pass)

This will create a Redis service with the --requirepass parameter set to the value of the redis-pass secret. The $(cat /run/secrets/redis-pass) command reads the value of the secret from the /run/secrets/redis-pass file.