Run container.
docker run \
--name <name>
--restart always \
-d \
-p 6379:6379 \
redis:<tag>
Run commands.
docker exec -it <name> redis-cli
> ping
> dbsize
Download redis.conf.
curl http://download.redis.io/redis-stable/redis.conf > redis.conf
Update requirepass setting.
requirepass pwd1 # use actual password
Run container.
docker run \
--name <name>
--restart always \
-d \
-p 6379:6379 \
-v /path/to/redis.conf:/etc/redis/redis.conf:ro \
redis:<tag> \
redis-server /etc/redis/redis.conf
Authenticate.
docker exec -it <name> redis-cli
> auth pwd1
> ping
Connect to server.
redis-cli -h <host> -p <port> -a <password>
> ping