|
| 1 | +--- |
| 2 | +categories: |
| 3 | +- docs |
| 4 | +- operate |
| 5 | +- stack |
| 6 | +- oss |
| 7 | +description: How to install Redis Stack using Docker |
| 8 | +linkTitle: Docker |
| 9 | +title: Run Redis Stack on Docker |
| 10 | +weight: 4 |
| 11 | +--- |
| 12 | + |
| 13 | +To get started with Redis Stack using Docker, you first need to select a Docker image: |
| 14 | + |
| 15 | +* `redis/redis-stack` contains both Redis Stack server and Redis Insight. This container is best for local development because you can use the embedded Redis Insight to visualize your data. |
| 16 | + |
| 17 | +* `redis/redis-stack-server` provides Redis Stack server only. This container is best for production deployment. |
| 18 | + |
| 19 | +## Getting started |
| 20 | + |
| 21 | +### redis/redis-stack-server |
| 22 | + |
| 23 | +To start Redis Stack server using the `redis-stack-server` image, run the following command in your terminal: |
| 24 | + |
| 25 | +{{< highlight bash >}} |
| 26 | +docker run -d --name redis-stack-server -p 6379:6379 redis/redis-stack-server:latest |
| 27 | +{{< / highlight >}} |
| 28 | + |
| 29 | +### redis/redis-stack |
| 30 | + |
| 31 | +To start a Redis Stack container using the `redis-stack` image, run the following command in your terminal: |
| 32 | + |
| 33 | +{{< highlight bash >}} |
| 34 | +docker run -d --name redis-stack -p 6379:6379 -p 8001:8001 redis/redis-stack:latest |
| 35 | +{{< / highlight >}} |
| 36 | + |
| 37 | +The `docker run` command above also exposes Redis Insight on port 8001. You can use Redis Insight by pointing your browser to `localhost:8001`. |
| 38 | + |
| 39 | +## Connect with redis-cli |
| 40 | + |
| 41 | +You can then connect to the server using `redis-cli`, just as you connect to any Redis instance. |
| 42 | + |
| 43 | +If you don’t have `redis-cli` installed locally, you can run it from the Docker container: |
| 44 | + |
| 45 | +{{< highlight bash >}} |
| 46 | +$ docker exec -it redis-stack redis-cli |
| 47 | +{{< / highlight >}} |
| 48 | + |
| 49 | +## Configuration |
| 50 | + |
| 51 | +### Persistence in Docker |
| 52 | + |
| 53 | +To mount directories or files to your Docker container, specify `-v` to configure a local volume. This command stores all data in the local directory `local-data`: |
| 54 | +{{< highlight bash >}} |
| 55 | +$ docker run -v /local-data/:/data redis/redis-stack:latest |
| 56 | +{{< / highlight >}} |
| 57 | + |
| 58 | +### Ports |
| 59 | + |
| 60 | +If you want to expose Redis Stack server or Redis Insight on a different port, update the left hand of portion of the `-p` argument. This command exposes Redis Stack server on port `10001` and Redis Insight on port `13333`: |
| 61 | +{{< highlight bash >}} |
| 62 | +$ docker run -p 10001:6379 -p 13333:8001 redis/redis-stack:latest |
| 63 | +{{< / highlight >}} |
| 64 | + |
| 65 | +### Config files |
| 66 | + |
| 67 | +By default, the Redis Stack Docker containers use internal configuration files for Redis. To start Redis with local configuration file, you can use the `-v` volume options: |
| 68 | + |
| 69 | +{{< highlight bash >}} |
| 70 | +$ docker run -v `pwd`/local-redis-stack.conf:/redis-stack.conf -p 6379:6379 -p 8001:8001 redis/redis-stack:latest |
| 71 | +{{< / highlight >}} |
| 72 | + |
| 73 | +### Environment variables |
| 74 | + |
| 75 | +To pass in arbitrary configuration changes, you can set any of these environment variables: |
| 76 | + |
| 77 | +* `REDIS_ARGS`: extra arguments for Redis |
| 78 | + |
| 79 | +* `REDISEARCH_ARGS`: arguments for the search and query features (RediSearch) |
| 80 | + |
| 81 | +* `REDISJSON_ARGS`: arguments for JSON (RedisJSON) |
| 82 | + |
| 83 | +* `REDISTIMESERIES_ARGS`: arguments for time series (RedisTimeSeries) |
| 84 | + |
| 85 | +* `REDISBLOOM_ARGS`: arguments for the probabilistic data structures (RedisBloom) |
| 86 | + |
| 87 | + |
| 88 | +For example, here's how to use the `REDIS_ARGS` environment variable to pass the `requirepass` directive to Redis: |
| 89 | + |
| 90 | +{{< highlight bash >}} |
| 91 | +docker run -e REDIS_ARGS="--requirepass redis-stack" redis/redis-stack:latest |
| 92 | +{{< / highlight >}} |
| 93 | + |
| 94 | +An example of setting [Redis persistence]({{< relref "/operate/oss_and_stack/management/persistence" >}}): |
| 95 | +{{< highlight bash >}} |
| 96 | +docker run -e REDIS_ARGS="--save 60 1000 --appendonly yes" redis/redis-stack:latest |
| 97 | +{{< / highlight >}} |
| 98 | + |
| 99 | +Here's how to set a retention policy for time series: |
| 100 | +{{< highlight bash >}} |
| 101 | +docker run -e REDISTIMESERIES_ARGS="RETENTION_POLICY=20" redis/redis-stack:latest |
| 102 | +{{< / highlight >}} |
0 commit comments