Skip to main content
Version: 3.1

Redis

Deprecation notice

Support for Portworx on the following orchestrators will be deprecated:

  • Docker Swarm and Docker Standalone
  • Nomad

For installation instructions on other platforms, refer to the Platform guides section.

This page provides instructions for deploying Redis with Portworx on Docker standalone.

Create a storage volume for Redis

To create a Portworx storage volume for Redis, use the docker volume create command:

docker volume create -d pxd --name=redis_vol --opt \
size=4 --opt block_size=64 --opt repl=1 --opt fs=ext4

Start the Redis container

To start the Redis container using the redis_vol volume created above, run the command below. (Use the Docker `-v’ option to attach the Portworx volume to the /data directory, which is where Redis stores its data).

docker run --name some-redis  -v redis_vol:/data --volume-driver=pxd  -d redis redis-server --appendonly yes

Your Redis container is now available for use on port 6379.

Start the redis CLI client container

docker run -it --link some-redis:redis --rm redis redis-cli -h redis -p 6379

Populate the redis instance with some data

set foo 100
OK
incr foo
(integer) 101
append foo abcxxx
(integer) 9
get foo
"101abcxxx"
redis:6379>

Kill the "some-redis" instance

docker kill some-redis

Start a new redis-server instance with volume persistence

Start another redis-server container called other-redis using the original redis_vol to show data persistence.

docker run --name other-redis  -v redis_vol:/data --volume-driver=pxd  -d redis redis-server --appendonly yes

Start a redis CLI container

Connect to the new other-redis container with the following command.

docker run -it --link other-redis:redis --rm redis redis-cli -h redis -p 6379

See that the original data has persisted

get foo
"101abcxxx"

Create snapshot of your volume

You can create container-granular snapshots, by saving just this container’s state. Snapshots are then immediately available as a volume.

Create a snapshot of the redis_vol volume using pxctl.

pxctl volume list
ID			NAME		SIZE	HA	STATUS
416765532972737036 redis_vol 2.0 GiB 1 up - attached on xxxxxxxx-xxxx-xxxx-xxxx-7b7cd5306b28
pxctl volume snapshot 416765532972737036
Volume successfully snapped:  3291428813175937263

Update the volume with new data

docker run -it --link other-redis:redis --rm redis redis-cli -h redis -p 6379
get foo
"101abcxxx"
set foo foobar
OK
get foo
"foobar"

See that the snapshot volume still contains the original data

docker run --name snap-redis -v 3291428813175937263:/data --volume-driver=pxd -d redis redis-server --appendonly yes
940d2ad6b87df9776e26d29e746eb05fb6081c0e6019d46ba77915d7c8305308
docker run -it --link snap-redis:redis --rm redis redis-cli -h redis -p 6379
get foo
"101abcxxx"
redis:6379>