Skip to main content
Version: 3.1


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
incr foo
(integer) 101
append foo abcxxx
(integer) 9
get foo

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

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 3abe5484-756c-4076-8a80-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
set foo foobar
get foo

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
docker run -it --link snap-redis:redis --rm redis redis-cli -h redis -p 6379
get foo
Was this page helpful?