Install Dragonfly Inside Docker Container in Linux

Install Dragonfly Inside Docker Container in Linux

Dragonfly is an in-memory key-value data structure store. It can be used as alternative for Redis and Memcached because Dragonfly is fully compatible with their APIs.

This tutorial explains how to install Dragonfly inside a Docker container in the 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 Dragonfly

  • Host network

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

docker run -d --name=dragonfly --restart=always --network=host \
    --ulimit memlock=-1 \
    -v /opt/dragonfly/data:/data \
    docker.dragonflydb.io/dragonflydb/dragonfly
  • User-defined bridge network

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

docker network create app-net
docker run -d --name=dragonfly --restart=always --network=app-net \
    -p 8080:6379 \
    --ulimit memlock=-1 \
    -v /opt/dragonfly/data:/data \
    docker.dragonflydb.io/dragonflydb/dragonfly

Testing Dragonfly

The telnet command can be used to test Dragonfly connectivity. Run the following command to connect to Dragonfly:

telnet 127.0.0.1 6379

Once connected, type PING command and press Enter to test whether the Dragonfly server can serve data. To exit telnet, type quit. Output example:

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

Uninstall Dragonfly

To completely remove Dragonfly, remove its container:

docker rm --force dragonfly

Remove Dragonfly image:

docker rmi docker.dragonflydb.io/dragonflydb/dragonfly

You can also remove Dragonfly data:

sudo rm -rf /opt/dragonfly

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.