How to Deploy Redis with Docker: Step-by-Step Guide and Configuration
This tutorial walks you through creating mount directories, configuring redis.conf, running a Redis container with Docker, and verifying the setup using redis-cli and a visual client, providing all necessary commands and explanations for a successful deployment.
Create mount directories for Redis configuration and data:
mkdir redis
# store configuration files
mkdir redis/conf
# store data files
mkdir redis/dataBecause a Redis container does not include a redis.conf file by default, download the appropriate version of the configuration file and place it in redis/conf. Typical settings you may need to adjust are:
# Protection mode, default is yes (only local access). Change to no for remote access.
protected-mode no
# Bind IP, comment out to allow external connections.
# bind 127.0.0.1
# Password for authentication.
requirepass 123456
# Persistence configuration to avoid data loss on restart.
appendonly noRun the Redis container with the mounted configuration and data directories:
docker run -d --name redis -p 6379:6379 \
-v D:\docker\redis\data:/data \
-v D:\docker\redis\conf\redis.conf:/etc/redis/redis.conf \
redis redis-server /etc/redis/redis.confDocker command options explained: -d: run the container in the background. --name: assign a name to the container. -p: map host port to container port. -v: mount configuration and data files. redis-server /etc/redis/redis.conf: start Redis using the specified config file.
After the container starts, you should see a success screenshot:
Enter the container to test the Redis instance:
docker exec -it redis /bin/bashConnect with redis-cli and perform a simple key‑value test:
# Connect
redis-cli -h localhost -p 6379 -a 123456
# Simple test
set test 1
get testConnection flags: -h: specify the Redis host IP. -p: specify the port. -a: specify the password (omit if none).
Successful test output appears as shown:
For visual management, you can use Another Redis Desktop Manager (download from GitHub ). After creating a new connection with the same host, port, and password, the client displays Redis overview and the key you stored earlier:
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
