Install KeyDB Inside Docker Container on Linux

Install KeyDB Inside Docker Container on Linux

KeyDB is an open-source, high-performance database that is fully compatible with Redis. It aims to provide enhanced performance and additional features compared to Redis, while maintaining compatibility with Redis clients and modules.

This tutorial explains how to install KeyDB inside a Docker container on Linux. Commands have been tested on Ubuntu.

Prepare environment

Make sure you have installed Docker in your system. If you are using Ubuntu, installation instructions can be found in the post.

Install KeyDB

  • Host network

Run the following command to create a container for KeyDB that uses host network:

docker run -d --name=keydb --restart=always --network=host \
    -v /opt/keydb/data:/data \
    eqalpha/keydb keydb-server --appendonly yes
  • User-defined bridge network

User-defined bridge network can be used for listening on different port. By default, KeyDB service is listening on port 6379. It can be changed with -p option.

docker network create app-net
docker run -d --name=keydb --restart=always --network=app-net \
    -p 8080:6379 \
    -v /opt/keydb/data:/data \
    eqalpha/keydb keydb-server --appendonly yes

Testing KeyDB

To test connectivity to KeyDB, the telnet command can be utilized. Use the following command to establish a connection to KeyDB:

telnet 127.0.0.1 6379

After connecting, enter the PING command and press Enter to check if the KeyDB server is responsive. To exit telnet, type quit. Example output:

Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
PING
+PONG
quit
+OK
Connection closed by foreign host.

Uninstall KeyDB

To completely remove KeyDB, remove its container:

docker rm --force keydb

Remove KeyDB image:

docker rmi eqalpha/keydb

You can also remove KeyDB data:

sudo rm -rf /opt/keydb

If a user-defined bridge network was created, you can delete it as follows:

docker network rm app-net

Leave a Comment

Cancel reply

Your email address will not be published.