Backend Development 15 min read

Deploying Redis Sentinel with Portainer and Integrating it into a Spring Boot Application

This tutorial walks through installing Portainer for Docker container management, creating docker‑compose files to deploy Portainer, setting up a master‑slave‑sentinel Redis architecture, configuring a custom bridge network, and finally integrating Redis Sentinel into a Spring Boot project with Lettuce connection pooling.

Architect's Guide
Architect's Guide
Architect's Guide
Deploying Redis Sentinel with Portainer and Integrating it into a Spring Boot Application

The article introduces Portainer as a graphical Docker management tool and explains how to install it using a simple docker-compose file named portainer.yml . After uploading the file to the server, the user starts Portainer in foreground mode with docker-compose -f portainer.yml up , accesses the UI at ip:9000 , and creates an admin account.

Once Portainer is running, the guide demonstrates how to use its UI to view containers, images, networks, and to manage Docker resources. The author then moves on to a practical example: deploying a Redis Sentinel cluster (one master, two slaves, three sentinel nodes) using Docker Compose.

First, a redis-cluster.yml file is created to define the master and slave services, with ports mapped to avoid the default 6379. The file is uploaded and started with docker-compose -f redis-cluster.yml up . After confirming the containers run, a custom bridge network called redis-sentinel is created in Portainer to isolate the Redis services.

Next, a redis-sentinel.yml compose file defines three sentinel containers, each mounting a host‑side sentinel.conf . The configuration files specify the master’s IP (obtained from the container’s network details) and authentication settings. The sentinel services are launched with docker-compose -f redis-sentinel.yml up , and their logs show automatic master election when the original master is stopped.

To make the sentinel setup usable from external applications, the article explains how to replace the internal master IP in the sentinel configuration with the server’s public IP.

Finally, the guide shows how to integrate the Redis Sentinel cluster into a Spring Boot application. It adds the spring-boot-starter-data-redis and commons-pool2 dependencies, explains why Lettuce is preferred over Jedis for thread‑safe connection pooling, and provides the necessary YAML configuration: spring: redis: password: xxxxx sentinel: master: redis-master nodes: :26379 password: xxxx lettuce: pool: max-idle: 10 max-active: 20 min-idle: 5 max-wait: 10000ms It then demonstrates injecting RedisTemplate into a controller, defining a simple DTO, and creating REST endpoints to set and get keys. The author verifies the integration by sending requests that store and retrieve data from the Redis Sentinel cluster. Overall, the article provides a step‑by‑step guide for using Portainer to manage Docker containers, deploying a robust Redis Sentinel architecture, and connecting it to a Spring Boot backend.

backendDockerSpring BootContainer ManagementPortainerRedis Sentinel
Architect's Guide
Written by

Architect's Guide

Dedicated to sharing programmer-architect skills—Java backend, system, microservice, and distributed architectures—to help you become a senior architect.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.