The official Hiredis docker image.
Maintained by: openEuler CloudNative SIG.
Where to get help: openEuler CloudNative SIG, openEuler.
Current Hiredis docker images are built on the openEuler. This repository is free to use and exempted from per-user rate limits.
Hiredis is a minimalistic C client library for the Redis database.
Learn more about Hiredis on Hiredis Website.
The tag of each hiredis docker image is consist of the version of hiredis and the version of basic image. The details are as follows
| Tag | Currently | Architectures |
|---|---|---|
| 1.4.1-oe2403sp4 | hiredis 1.4.1 on openEuler 24.03-LTS-SP4 | amd64, arm64 |
| 1.3.0-oe2403sp4 | Hiredis 1.3.0 on openEuler 24.03-LTS-SP4 | amd64, arm64 |
| 1.3.0-oe2403sp1 | Hiredis 1.3.0 on openEuler 24.03-LTS-SP1 | amd64, arm64 |
In this usage, users can select the corresponding {Tag} based on their requirements.
Pull the openeuler/hiredis image from docker
docker pull openeuler/hiredis:{Tag}
Redis client example with hiredis
This example demonstrates how to connect to a Redis server and execute basic commands using the Hiredis client library in C.
The example connects to a Redis server running on 127.0.0.1 at port 6379, sends a PING command, and prints the response.
Ensure you have Redis installed and running. You can start the Redis server using the following commands:
dnf install -y redis
nohup redis-server /etc/redis.conf --daemonize no > /var/log/redis.log 2>&1 &
Example: A minimal hiredis program
Create a file named hiredis.c with the following content:
#include <stdlib.h>
#include <hiredis/hiredis.h>
int main() {
// Connect to Redis (default: 127.0.0.1:6379)
redisContext *c = redisConnect("127.0.0.1", 6379);
// Check connection status
if (c == NULL || c->err) {
printf("Connection failed: %s\n", c ? c->errstr : "Memory allocation failed");
exit(1); // Exit with error code
}
printf("Redis connection established!\n");
// Execute PING command
redisReply *reply = redisCommand(c, "PING");
printf("PING response: %s\n", reply->str);
// Free reply memory
freeReplyObject(reply);
// Close connection
redisFree(c);
return 0; // Exit successfully
}
Compilation
Compile the hiredis.c program using the following command:
gcc -o hiredis hiredis.c -lhiredis
Execution
Run the compiled binary using the following command:
./hiredis
Output
Redis connection established!
PING response: PONG
If you have any questions or want to use some special features, please submit an issue or a pull request on openeuler-docker-images.
Content type
Image
Digest
sha256:802737387…
Size
198 MB
Last updated
about 21 hours ago
docker pull openeuler/hiredisPulls:
2
Last week