This is a step-by-step guide to creating a custom Redis image in case of fine tuned Redis configurations/customizations/disaster recovery.
- Docker
-
Create a new directory for your project.
mkdir redis-testing cd redis-testing
-
Create a new Dockerfile in the root of your project.
cd > Dockerfile -
Run a container with the
redis/redis-stackimage.docker run -it --rm --name redis-stack -p 6379:6379 -p 8001:8001 redis/redis-stack:latest
-
Inspect the container.
docker inspect --name redis-stack
-
Take note of the ENV and the CMD. We will need these later.
-
Stop the container, then export the container.
docker stop redis-stack docker export --name redis-stack redis-stack-container.tar
This will create a file called
redis-stack-container.tarin the current directory. -
Add the location of the
redis-stack-container.tarfile to the Dockerfile with COPY to copy it into the container (target the container root directory). -
Build the image.
docker build -t redis-testing .
-
Run the image.
docker run -it --rm --name redis-testing -p 6379:6379 -p 8001:8001 redis-testing