dhi.io/valkey
Valkey is a high-performance key/value datastore that supports a variety of workloads such as caching, message queues, and can act as a primary database.
All examples in this guide use the public image. If you’ve mirrored the repository for your own use (for example, to your Docker Hub namespace), update your commands to reference the mirrored image instead of the public one.
For example:
dhi.io/<repository>:<tag><your-namespace>/dhi-<repository>:<tag>For the examples, you must first use docker login dhi.io to authenticate to the registry to pull the images.
This Docker Hardened Valkey image includes the complete Valkey toolkit in a single, security-hardened package:
valkey-server: The main Valkey servervalkey-cli: Valkey command-line interfacevalkey-benchmark: Performance testing toolvalkey-check-aof: AOF file checker and repairervalkey-check-rdb: RDB file checkerFor Redis compatibility, the image also includes symbolic links that allow you to use the traditional Redis command names:
redis-server -> valkey-serverredis-cli -> valkey-cliredis-benchmark -> valkey-benchmarkredis-sentinel -> valkey-serverredis-check-aof -> valkey-check-aofredis-check-rdb -> valkey-check-rdbRun the following command to run a Valkey container and output the help. Replace <tag> with the image variant you want
to run.
$ docker run --rm dhi.io/valkey:<tag> valkey-server --help
Start a Valkey server instance:
$ docker run --name my-valkey -d dhi.io/valkey:<tag> valkey-server
Connect to the server using the valkey-cli:
$ docker exec -it my-valkey valkey-cli ping
PONG
Run Valkey with data persistence using a Docker volume:
$ docker run --name valkey-persistent -d \
-v valkey-data:/data \
dhi.io/valkey:<tag> sh -c "cd /data && valkey-server --appendonly yes"
This enables AOF (Append-Only File) persistence, which logs every write operation to ensure data durability. The data will be stored in the Docker volume and persist across container restarts.
Create a custom-valkey.conf file:
port 6380
maxmemory 128mb
maxmemory-policy volatile-lru
timeout 300
loglevel verbose
databases 8
Create a compose.yml file:
services:
valkey-custom:
image: dhi.io/valkey:<tag>
container_name: valkey-custom
ports:
- "6380:6380"
volumes:
- "./custom-valkey.conf:/tmp/valkey.conf:ro"
command: valkey-server /tmp/valkey.conf
Run with Docker Compose:
$ docker compose up -d
The -sentinel image variant (for example, dhi.io/valkey:<tag>-sentinel, and -sentinel-fips for the FIPS build)
starts Valkey in Sentinel mode rather than as a standalone server. Sentinel monitors your Valkey primary and replicas,
performs automatic failover, and acts as a discovery service for clients. It starts with the valkey-sentinel entry
point using /etc/valkey/sentinel.conf and listens on port 26379:
$ docker run --name valkey-sentinel -d -p 26379:26379 dhi.io/valkey:<tag>-sentinel
The image ships a writable /etc/valkey/sentinel.conf owned by the nonroot user (uid/gid 65532), and Sentinel
rewrites this file at runtime (CONFIG REWRITE) as it records the primary it monitors, the replicas it discovers, and
failover state. Add your sentinel monitor <name> <ip> <port> <quorum> directive to that config, for example by baking
it into your own image layer or mounting a replacement config into /etc/valkey.
Because Sentinel must rewrite its own configuration, the config file and the /etc/valkey directory must stay writable
by the nonroot user. A read-only or root-owned Sentinel config is the most common reason a Sentinel container fails
under the hardened image, as Sentinel exits when it cannot persist its state.
To use the Valkey hardened image in Kubernetes, set up authentication and
update your Kubernetes deployment. For example, in your valkey.yaml file, replace the image reference in the container
spec. In the following example, replace <tag> with your organization's namespace and the desired tag.
apiVersion: apps/v1
kind: Deployment
metadata:
name: valkey
namespace: <kubernetes-namespace>
spec:
template:
spec:
containers:
- name: valkey
image: dhi.io/valkey:<tag>
ports:
- containerPort: 6379
imagePullSecrets:
- name: <your-registry-secret>
Then apply the manifest to your Kubernetes cluster.
$ kubectl apply -n <kubernetes-namespace> -f valkey.yaml
| Feature | Valkey non-hardened image | Valkey Docker Hardened Image |
|---|---|---|
| Base OS | Debian and Alpine | Debian |
| User context | Runs as root (uid/gid 0) | Runs as nonroot user (uid/gid 65532) |
| Shell access | Full shell available | No shell or shell utilities |
| Package management | Package manager included | No package manager |
| Attack surface | Larger due to root user and additional utilities | Minimal, only essential Valkey components |
| Security posture | Standard container security | Ships with SBOM and VEX metadata |
| Debugging | Traditional shell debugging and root access | Use Docker Debug or image mount for tooling |
Docker Hardened Images prioritize security through minimalism:
The hardened images intended for runtime don't contain a shell nor any tools for debugging. Common debugging methods for applications built with Docker Hardened Images include:
Docker Debug provides a shell, common debugging tools, and lets you install other tools in an ephemeral, writable layer that only exists during the debugging session.
For example, you can use Docker Debug:
docker debug <image-name>
or mount debugging tools with the image mount feature:
docker run --rm -it --pid container:my-container \
--mount=type=image,source=dhi.io/busybox,destination=/dbg,ro \
dhi.io/<image-name>:<tag> /dbg/bin/sh
Docker Hardened Images come in different variants depending on their intended use. The Valkey image ships the runtime
variant, plus a -sentinel flavor (tags dhi.io/valkey:<tag>-sentinel and -sentinel-fips) that starts in Sentinel
mode for high-availability deployments (see
Run Valkey in Sentinel mode above). Runtime variants are designed to
run your application in production. These images are intended to be used either directly or as the FROM image in the
final stage of a multi-stage build. These images typically:
Switching to the hardened Valkey image requires minimal changes for most use cases.
Replace the image reference in your configuration file or command.
If using custom configuration files, update mount paths to writable locations for the nonroot user.
All your existing environment variables, port mappings, and volume mounts for data persistence remain the same.
The following are common issues that you may encounter during migration.
The hardened images intended for runtime don't contain a shell nor any tools for debugging. The recommended method for debugging applications built with Docker Hardened Images is to use Docker Debug to attach to these containers. Docker Debug provides a shell, common debugging tools, and lets you install other tools in an ephemeral, writable layer that only exists during the debugging session.
By default image variants intended for runtime, run as the nonroot user. Ensure that necessary files and directories are accessible to the nonroot user. You may need to copy files to different directories or change permissions so your application running as the nonroot user can access them.
Non-dev hardened images run as a nonroot user by default. As a result, applications in these images can't bind to
privileged ports (below 1024) when running in Kubernetes or in Docker Engine versions older than 20.10. To avoid issues,
configure your application to listen on port 1025 or higher inside the container, even if you map it to a lower port on
the host. For example, docker run -p 80:8080 my-image will work because the port inside the container is 8080, and
docker run -p 80:81 my-image won't work because the port inside the container is 81.
By default, image variants intended for runtime don't contain a shell. Use dev images in build stages to run shell
commands and then copy any necessary artifacts into the runtime stage. In addition, use Docker Debug to debug containers
with no shell.
Docker Hardened Images may have different entry points than images such as Docker Official Images. Use docker inspect
to inspect entry points for Docker Hardened Images and update your Dockerfile if necessary.