Valkey is an in-memory key-value data structure store, forked from the open-source Redis project just before Redis transitioned to its new source-available licenses.
This tutorial explains how to install Valkey 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 Valkey
- Host network
Run the following command to create a container for Valkey that uses host network:
docker run -d --name=valkey --restart=always --network=host \
-v /opt/valkey/data:/data \
valkey/valkey valkey-server --save 60 1
- User-defined bridge network
User-defined bridge network can be used for listening on different port. By default, Valkey service is listening on port 6379. It can be changed with -p
option.
docker network create app-net
docker run -d --name=valkey --restart=always --network=app-net \
-p 8080:6379 \
-v /opt/valkey/data:/data \
valkey/valkey valkey-server --save 60 1
Testing Valkey
Use the following command to launch the Valkey CLI and run the PING command to check if the connection is active and the Valkey server is responsive:
docker exec -it valkey valkey-cli PING
Uninstall Valkey
To completely remove Valkey, remove its container:
docker rm --force valkey
Remove Valkey image:
docker rmi valkey/valkey
You can also remove Valkey data:
sudo rm -rf /opt/valkey
If a user-defined bridge network was created, you can delete it as follows:
docker network rm app-net
Leave a Comment
Cancel reply