You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/operate/oss_and_stack/install/install-stack/docker.md
+17-65Lines changed: 17 additions & 65 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,93 +12,45 @@ weight: 1
12
12
13
13
## Run Redis Community Edition (CE) on Docker
14
14
15
-
To get started with Redis CE using Docker, you first need to select a Docker image:
16
-
17
-
*`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.
18
-
19
-
*`redis/redis-stack-server` provides Redis Stack server only. This container is best for production deployment.
20
-
21
-
## Getting started
22
-
23
-
### redis/redis-stack-server
24
-
25
-
To start Redis Stack server using the `redis-stack-server` image, run the following command in your terminal:
15
+
To start Redis Community Edition server, using the `redis:<version>` image, run the following command in your terminal:
26
16
27
17
{{< highlight bash >}}
28
-
docker run -d --name redis-stack-server -p 6379:6379 redis/redis-stack-server:latest
18
+
docker run -d --name redis -p 6379:6379 redis:<version>
29
19
{{< / highlight >}}
30
20
31
-
### redis/redis-stack
32
-
33
-
To start a Redis Stack container using the `redis-stack` image, run the following command in your terminal:
34
-
35
-
{{< highlight bash >}}
36
-
docker run -d --name redis-stack -p 6379:6379 -p 8001:8001 redis/redis-stack:latest
37
-
{{< / highlight >}}
38
-
39
-
The `docker run` command above also exposes Redis Insight on port 8001. You can use Redis Insight by pointing your browser to `localhost:8001`.
40
-
41
21
## Connect with redis-cli
42
22
43
23
You can then connect to the server using `redis-cli`, just as you connect to any Redis instance.
44
24
45
25
If you don’t have `redis-cli` installed locally, you can run it from the Docker container:
46
26
47
27
{{< highlight bash >}}
48
-
$ docker exec -it redis-stack redis-cli
49
-
{{< / highlight >}}
50
-
51
-
## Configuration
52
-
53
-
### Persistence in Docker
54
-
55
-
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`:
56
-
{{< highlight bash >}}
57
-
$ docker run -v /local-data/:/data redis/redis-stack:latest
58
-
{{< / highlight >}}
59
-
60
-
### Ports
61
-
62
-
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`:
63
-
{{< highlight bash >}}
64
-
$ docker run -p 10001:6379 -p 13333:8001 redis/redis-stack:latest
28
+
$ docker exec -it redis redis-cli
65
29
{{< / highlight >}}
66
30
67
-
### Config files
68
-
69
-
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:
31
+
If you do have `redis-cli` installed locally, you can run it from your terminal:
70
32
71
33
{{< highlight bash >}}
72
-
$ docker run -v `pwd`/local-redis-stack.conf:/redis-stack.conf -p 6379:6379 -p 8001:8001 redis/redis-stack:latest
34
+
$ redis-cli -h 127.0.0.1 -p 6379
73
35
{{< / highlight >}}
74
36
75
-
### Environment variables
76
-
77
-
To pass in arbitrary configuration changes, you can set any of these environment variables:
78
-
79
-
*`REDIS_ARGS`: extra arguments for Redis
37
+
## Use a local configuration file
80
38
81
-
*`REDISEARCH_ARGS`: arguments for the search and query features (RediSearch)
39
+
By default, the Redis Docker containers use internal configuration files for Redis. To start Redis with local configuration file, you can do one of the following:
82
40
83
-
*`REDISJSON_ARGS`: arguments for JSON (RedisJSON)
41
+
You can create your own Dockerfile that adds a `redis.conf` from the context into `/data/`, like so.
84
42
85
-
*`REDISTIMESERIES_ARGS`: arguments for time series (RedisTimeSeries)
86
-
87
-
*`REDISBLOOM_ARGS`: arguments for the probabilistic data structures (RedisBloom)
88
-
89
-
90
-
For example, here's how to use the `REDIS_ARGS` environment variable to pass the `requirepass` directive to Redis:
Alternatively, you can specify something along the same lines with docker run options.
91
49
92
50
{{< highlight bash >}}
93
-
docker run -e REDIS_ARGS="--requirepass redis-stack" redis/redis-stack:latest
51
+
$ docker run -v /myredis/conf:/usr/local/etc/redis --name myredis redis redis-server /usr/local/etc/redis/redis.conf
94
52
{{< / highlight >}}
95
53
96
-
An example of setting [Redis persistence]({{< relref "/operate/oss_and_stack/management/persistence" >}}):
97
-
{{< highlight bash >}}
98
-
docker run -e REDIS_ARGS="--save 60 1000 --appendonly yes" redis/redis-stack:latest
99
-
{{< / highlight >}}
54
+
where `/myredis/conf/` is a local directory containing your `redis.conf` file. Using this method means that there is no need for you to have a Dockerfile for your redis container.
100
55
101
-
Here's how to set a retention policy for time series:
102
-
{{< highlight bash >}}
103
-
docker run -e REDISTIMESERIES_ARGS="RETENTION_POLICY=20" redis/redis-stack:latest
104
-
{{< / highlight >}}
56
+
The mapped directory should be writable, as depending on the configuration and mode of operation, Redis may need to create additional configuration files or rewrite existing ones.
0 commit comments