How to Deploy and Run Redis in a Docker container
- Redis Enterprise
- Redis
#
Pre-requisiteEnsure that Docker is installed in your system.
If you're new, refer https://docs.docker.com/docker-for-mac/install/ to install Docker on Mac.
To pull and start the Redis Enterprise Software Docker container, run this docker run command in the terminal or command-line for your operating system.
Note: On Windows, make sure Docker is configured to run Linux-based containers.
In the web browser on the host machine, go to https://localhost:8443 to see the Redis Enterprise Software web console.
#
Step 1: Click on “Setup”Click Setup to start the node configuration steps.
#
Step 2: Enter your preferred FQDNIn the Node Configuration settings, enter a cluster FQDN such as demo.redis.com. Then click Next button.
Enter your license key, if you have one. If not, click the Next button to use the trial version.
#
Step 3: Enter the admin credentialsEnter an email and password for the admin account for the web console.
These credentials are also used for connections to the REST API. Click OK to confirm that you are aware of the replacement of the HTTPS SSL/TLS certificate on the node, and proceed through the browser warning.
#
Step 4: Create a Database:Select “redis database” and the “single region” deployment, and click Next.
Enter a database name such as demodb and click Activate to create your database
You now have a Redis database!
#
Step 5: Connecting using redis-cliAfter you create the Redis database, you are ready to store data in your database. redis-cli is a built-in simple command-line tool to interact with Redis database. Run redis-cli, located in the /opt/redislabs/bin directory, to connect to port 12000 and store and retrieve a key in database1
#
Pre-requisiteEnsure that Docker is installed in your system. Follow https://docs.docker.com/engine/install/ if you haven’t installed yet.
You can run Redis Stack using a Docker container. There are two types of Docker images available in Docker Hub.
The
redis/redis-stack
Docker image contains both Redis Stack server and RedisInsight. This container is recommended for local development because you can use RedisInsight to visualize your data.The
redis/redis-stack-server
provides Redis Stack but excludes RedisInsight. This container is best for production deployment.
#
Getting startedTo start Redis Stack server using the redis-stack image, run the following command in your terminal:
You can use redis-cli
to connect to the server, just as you connect to any Redis instance.
If you don’t have redis-cli installed locally, you can run it from the Docker container:
TIP
The docker run
command above also exposes RedisInsight on port 8001. You can use RedisInsight by pointing your browser to http://localhost:8001.
To persist your Redis data to a local path, specify -v to configure a local volume. This command stores all data in the local directory local-data:
If you want to expose Redis Stack server or RedisInsight on a different port, update the left hand of portion of the -p
argument. This command exposes Redis Stack server on port 10001 and RedisInsight on port 13333:
By default, the Redis Stack Docker containers use internal configuration files for Redis. To start Redis with local a configuration file, you can use the -v volume options:
To pass in arbitrary configuration changes, you can set any of these environment variables:
REDIS_ARGS
: extra arguments for RedisREDISEARCH_ARGS
: arguments for RediSearchREDISJSON_ARGS
: arguments for RedisJSONREDISGRAPH_ARGS
: arguments for RedisGraphREDISTIMESERIES_ARGS
: arguments for RedisTimeSeriesREDISBLOOM_ARGS
: arguments for RedisBloom
For example, here’s how to use the REDIS_ARGS
environment variable to pass the requirepass
directive to Redis: