Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment variables for Username / Password #46

Open
ninode97 opened this issue Dec 18, 2024 · 1 comment
Open

Environment variables for Username / Password #46

ninode97 opened this issue Dec 18, 2024 · 1 comment

Comments

@ninode97
Copy link

Hello.

I try to understand, what environment variables it accepts?

Is this correct:

services:
  valkey:
    image: valkey/valkey:latest # Replace with the correct image if available on Docker Hub
    container_name: valkey
    ports:
      - '6379:6379' # Map container port 6379 (default Redis port) to host
    volumes:
      - valkey_data:/data # Mount volume to persist data
    environment:
      - REDIS_USER=x-user
      - REDIS_PASSWORD=x-pass
      - REDIS_DB=x-test
    networks:
      - valkey_network

I keep getting Unhandled error event: ReplyError: WRONGPASS invalid username-password pair or user is disabled.

@AlfredoRamos
Copy link

Hi,

As far as I know, it does not use environment variables. You can use a custom configuration file, or additional command arguments.

I use the following to set a password for the default user with --requirepass <password>.

  valkey:
    image: valkey/valkey:8-alpine
    user: 'valkey'
    restart: unless-stopped
    command: >
      --requirepass "${CACHE_PASS}"
    healthcheck:
      test:
        [
          'CMD-SHELL',
          "echo 'auth ${CACHE_PASS}\nping' | valkey-cli -h '${CACHE_HOST}' | grep 'PONG'",
        ]
      interval: 1m
      timeout: 30s
      retries: 3
      start_period: 60s
    networks:
      - cache
    volumes:
      - cachedata:/data

.env

...
CACHE_HOST=valkey
CACHE_PASS=
...

You could do something similar with a username too (not tested):

--user [...]

https://valkey.io/topics/acl/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants