Redis is one of the most popular Docker images and is often used as a super-fast in-memory database like cache, session store, or message broker. In this article we show you step by step how to use Redis with Docker and how to connect it to other Docker containers or external applications.
Dedicated servers
Performance and innovation
- Latest generation processors
- High performance dedicated hardware
- ISO certified data centers
Benefits of running Redis in Docker
- Rapid deployment thanks to preconfigured images
- Portability across different environments
- Ease of scaling and automation with Docker Compose or Kubernetes
- Good insulation for development, test and production environments
- Easy integration in microservices architectures
Prerequisites
To use Redis in Docker, you need:
- A Linux server with Docker installation, for example Ubuntu 24.04, Debian 12 or AlmaLinux 9
- Basic knowledge of using the command line
- Optional: wireless access
sudoby becoming a member of the Docker group
Step 1: Start a Docker Redis container
With the following command you start a simple container Redis Dockerwhich stores its data persistently:
sudo docker run --name my-redis-container -d redis
bash
The official image Redis of the Docker hub uses port 6379 by default and is ready to use.
Step 2: Connect a Docker Redis instance, container to container
Use a custom network to connect your instance of Redis server in Docker to other containers:
docker network create redis-net
docker run --name my-redis-container --network redis-net -d redis
docker run --name my-redis-client --network redis-net -it redis redis-cli -h my-redis-container
bash
Thus, Redis integrates seamlessly with backend services, microservices or admin tools without the option --linkwhich has become obsolete.
SSL certificates
Choose security
- Secure your data transfers
- Build trust with your customers
- Improve your positioning on Google
Step 3: Allow access to Docker Redis containers from outside
If you want to use Redis internally but also externally (for example via a remote server), enable port forwarding:
docker run --name my-redis-container -p 7001:6379 -d redis
bash
Access from the client:
redis-cli -h [hôte-IP ou domaine] -p 7001
bash
Note
Open the port in your firewall and secure your instance with a password in redis.conf.
Step 4: Use a redis.conf custom in container
You can provide custom configuration for the Redis server in Docker :
docker run --name my-redis-container \
-v /data/myredis/redis.conf:/usr/local/etc/redis/redis.conf
redis redis-server /usr/local/etc/redis/redis.conf
bash
This allows individual settings such as authentication (requirepass), memory limits or replication.
Configuring Redis in Docker with Docker Compose
For larger projects, it is recommended to use Docker Compose:
version: '3'
services:
redis:
image: redis
ports:
- "6379:6379"
volumes:
- redis-data:/data
volumes:
redis-data:
bash
Start your environment with:
Best practices for Redis Docker servers
- Activate
requirepassto secure your Redis instance - Use TLS/SSL for encrypted communications
- Store data in Docker volumes for persistent storage
- Monitor containers with Docker logs, Redis CLI or monitoring tools
- Keep Redis and Docker images regularly updated
In summary
A Redis Docker container isinstalls in minutes and is perfect for local development and production infrastructure. Thanks to the image Redis officialclear network concepts and simple configuration, Redis can quickly connect to other Docker containers and operate safely. With Docker Compose, your own redis.conf and best practices, you get the most out of your setup.

