---
# System prepended metadata

title: Redis

---

# Redis

## Requirments
- Redis 6.x
- RedisJSON 2.0

## Redis GUI Clients (Cross Platform)
- [RedisInsight](https://redis.com/redis-enterprise/redis-insight) - (Java Web App)
- [RDM](https://rdm.dev) - (Free on linux only)
- [AnotherRedisDesktopManager](https://github.com/qishibo/AnotherRedisDesktopManager)

### RedisInsight on Docker
You could download `RedisInsight` and run it on your host machine on port `8001`.
You could run it on Docker using the following command.

```sh
$ docker run -v redisinsight:/db --restart=no --name redis-client -d -p 3030:8001 redislabs/redisinsight:latest
$ docker network create redis
$ docker network connect redis redis-client
```
> Notes:
> - To start the contaiiner manually use `--restart=no`.
> - To start the contaiiner on startup use `--restart=unless-stopped` instead.
> - We use `redis-client` as the container name, you could change the name as you like.
> - To access RedisInsight on port `3030` we map docker `8001` internal port to `3030` host port.
> - After running the container, you could access RedisInsight on (http://localhost:3030).
> - We need to create a virtual network `redis` that connect `RedisInsight` with **redis instances** running on docker.

## Redis Instance on Docker
The module `RedisJSON 2.0` is now in preview, so we are limitted to the following docker images
- `redislabs/redismod:preview` (Redis 6.0.4 - Contains all official redis modules).
- `redislabs/rejson:preview` (Redis 6.2.4 - Small Size - Contains only RedisJSON Module).

```sh
# redislabs/redismod:preview
$ docker run -v redis-preview:/data --restart=no --name redis-preview -d -p 6379:6379 redislabs/redismod:preview
$ docker network connect redis redis-preview
```

```sh
# redislabs/rejson:preview
$ docker run -v redis-rejson-preview:/data --restart=no --name redis-rejson-preview -d -p 6379:6379 redislabs/rejson:preview
$ docker network connect redis redis-rejson-preview
```

> We need to run the container and add it to `redis` virtual network we created before.
> we could run diffrent versions, use different name and map to different port for example `6380:6379`.

### Connect to Redis on Docker
We could connect to outside docker using
- `Host: localhost`
- `Port: 6379` (if not mapped to different port)
- `Username: [default]`
- `Password: [None]`

We could connect to inside docker, after connecting to the same virtual network using
- `Host: [continer-name]` such as (redis-preview, redis-rejson-preview)
- `Port: 6379` (even if maaped outside to different port)
- `Username: [default]`
- `Password: [None]`

### Additionally, If you want to use your own redis.conf ...
> The following is a copy from `redis` images repo, the same config could be used with the preview images.
You can create your own Dockerfile that adds a redis.conf from the context into /data/, like so.

```
FROM redis
COPY redis.conf /usr/local/etc/redis/redis.conf
CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ]
```

Alternatively, you can specify something along the same lines with docker run options.

```sh
$ docker run -v /myredis/conf:/usr/local/etc/redis --name myredis redis redis-server /usr/local/etc/redis/redis.conf
```
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.
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.

## Powershell Function (Optional)
You could add the following functions in `$PROFILE`,
to enable `start-redis` and `stop-redis` as commands to be used in powershell.
```ps1
Function start-redis {docker start redis-client && docker start redis-rejson-preview }
Function stop-redis {docker stop redis-client && docker stop redis-rejson-preview }
```
