Using Redis for caching on Rocky Linux 10 is not as straight forward as it looks. The Redis package is removed from the official repositpories and if you want to install it you need Remi repo, which is one of the option to run Redis. However I decided to go for another option and install it in container. Because I will use it only locally, the port is not open in firewalld.
Install podman
On Rocky Linux 10 the default engine for running containers is podman and I need to install it in order to get the container up and running.
sudo dnf install -y podman
Once podman is installed you can check it with:
podman version
Creating a new container with redis image is straight process, however if we want our container to be booted automatically after a reboot we need to define it as quadlet.
What is quadlet
Quadlet is a systemd definition for a container. This gives you several advantages - to run as a service, to get updates on the container image, to get everything documented in a file. It can be run both as root user or as a regular one. The only limitation is that if run as a non-priviledge user, it can only use ports above 1024. We will create our quadlet as privilege user.
Let’s define the quadlet and put it inside /etc/containers/systemd/redis.container.
[Unit]
Description=Redis
[Container]
ContainerName=redis
Image=docker.io/library/redis:8-trixie
AutoUpdate=registry
PublishPort=6379:6379
[Service]
Restart=always
[Install]
WantedBy=default.target
After the systemd file is created and placed in the directory mentioned above you should do:
sudo systemctl daemon-reload
sudo systemctl start redis
The command might take a while, cause it is downloading and startign the container.
Finally check for the running systemd service and listening port.
ss -nlte | grep 6379
systemctl status redis
Let’s try connecting to the server with netcat:
echo -e '*1\r\n$4\r\nPING\r\n' | nc localhost 6379
If connection is successful you should receive PONG.
References
More info on the Quadlets can be found in the man pages.
Install open-source alternative to Redis - Valkey, included in Rocky10 repos, instructions here.