Ping Redis without CURL or NC | Christopher Vachon

Ping Redis without CURL or NC

2018-03-05

I recently needed to ping for Redis from a docker container to make sure it was reachable. The issue being that you cant restart a docker container to install anything because the changes will not persists without rebuilding the container.

I found this little snippet on Stack Overflow which allowed me to check the Redis connection from inside my container.

exec 3<>/dev/tcp/<YourRedisServerAddress>/6379 && echo -e "PING\r\n" >&3 && head -c 7 <&3

assuming you can connect to the server and everything is find, you should be the response +PONG to your PING endpoint request.

References