# Dev Services for Redis

Quarkus supports a feature called Dev Services that allows you to create various datasources without any config. What that means practically, is that if you have docker running and have not configured `quarkus.redis.hosts`, Quarkus will automatically start a Redis container when running tests or dev mode, and automatically configure the connection.

Available properties to customize the Redis DevService.

Configuration property fixed at build time - All other configuration properties are overridable at runtime

Configuration property | Type | Default
--- | --- | ---
`quarkus.redis.devservices.enabled` If DevServices has been explicitly enabled or disabled. DevServices is generally enabled by default, unless there is an existing configuration present. When DevServices is enabled Quarkus will attempt to automatically configure and start a database when running in Dev or Test mode and when Docker is running. Environment variable: `QUARKUS_REDIS_DEVSERVICES_ENABLED` | boolean | `true`
`quarkus.redis.devservices.image-name` The container image name to use, for container based DevServices providers. If you want to use Redis Stack modules (bloom, graph, search…​), use: `redis/redis-stack-server:latest`. Environment variable: `QUARKUS_REDIS_DEVSERVICES_IMAGE_NAME` | string |
`quarkus.redis.devservices.port` Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly. Environment variable: `QUARKUS_REDIS_DEVSERVICES_PORT` | int |
`quarkus.redis.devservices.shared` Indicates if the Redis server managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. If a matching container is found, it is used, and so a second one is not started. Otherwise, Dev Services for Redis starts a new container. The discovery uses the `quarkus-dev-service-redis` label. The value is configured using the `service-name` property. Container sharing is only used in dev mode. Environment variable: `QUARKUS_REDIS_DEVSERVICES_SHARED` | boolean | `true`
`quarkus.redis.devservices.service-name` The value of the `quarkus-dev-service-redis` label attached to the started container. This property is used when `shared` is set to `true`. In this case, before starting a container, Dev Services for Redis looks for a container with the `quarkus-dev-service-redis` label set to the configured value. If found, it will use this container instead of starting a new one. Otherwise, it starts a new container with the `quarkus-dev-service-redis` label set to the specified value. This property is used when you need multiple shared Redis servers. Environment variable: `QUARKUS_REDIS_DEVSERVICES_SERVICE_NAME` | string | `redis`
`quarkus.redis.devservices.container-env` Environment variables that are passed to the container. Environment variable: `QUARKUS_REDIS_DEVSERVICES_CONTAINER_ENV` | `Map<String,String>` |
`quarkus.redis."additional-redis-clients".devservices.enabled` If DevServices has been explicitly enabled or disabled. DevServices is generally enabled by default, unless there is an existing configuration present. When DevServices is enabled Quarkus will attempt to automatically configure and start a database when running in Dev or Test mode and when Docker is running. Environment variable: `QUARKUS_REDIS__ADDITIONAL_REDIS_CLIENTS__DEVSERVICES_ENABLED` | boolean | `true`
`quarkus.redis."additional-redis-clients".devservices.image-name` The container image name to use, for container based DevServices providers. If you want to use Redis Stack modules (bloom, graph, search…​), use: `redis/redis-stack-server:latest`. Environment variable: `QUARKUS_REDIS__ADDITIONAL_REDIS_CLIENTS__DEVSERVICES_IMAGE_NAME` | string |
`quarkus.redis."additional-redis-clients".devservices.port` Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly. Environment variable: `QUARKUS_REDIS__ADDITIONAL_REDIS_CLIENTS__DEVSERVICES_PORT` | int |
`quarkus.redis."additional-redis-clients".devservices.shared` Indicates if the Redis server managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. If a matching container is found, it is used, and so a second one is not started. Otherwise, Dev Services for Redis starts a new container. The discovery uses the `quarkus-dev-service-redis` label. The value is configured using the `service-name` property. Container sharing is only used in dev mode. Environment variable: `QUARKUS_REDIS__ADDITIONAL_REDIS_CLIENTS__DEVSERVICES_SHARED` | boolean | `true`
`quarkus.redis."additional-redis-clients".devservices.service-name` The value of the `quarkus-dev-service-redis` label attached to the started container. This property is used when `shared` is set to `true`. In this case, before starting a container, Dev Services for Redis looks for a container with the `quarkus-dev-service-redis` label set to the configured value. If found, it will use this container instead of starting a new one. Otherwise, it starts a new container with the `quarkus-dev-service-redis` label set to the specified value. This property is used when you need multiple shared Redis servers. Environment variable: `QUARKUS_REDIS__ADDITIONAL_REDIS_CLIENTS__DEVSERVICES_SERVICE_NAME` | string | `redis`
`quarkus.redis."additional-redis-clients".devservices.container-env` Environment variables that are passed to the container. Environment variable: `QUARKUS_REDIS__ADDITIONAL_REDIS_CLIENTS__DEVSERVICES_CONTAINER_ENV` | `Map<String,String>` |

When running the production version of the application, the Redis connection need to be configured as normal, so if you want to include a production database config in your `application.properties` and continue to use Dev Services we recommend that you use the `%prod.` profile to define your Redis settings.

Dev Services for Redis relies on Docker to start the server. If your environment does not support Docker, you will need to start the server manually, or connect to an already running server.

| If you want to use Redis Stack modules (bloom, graph, search…​), set the image-name to `redis/redis-stack:latest`

## Shared server

Most of the time you need to share the server between applications. Dev Services for Redis implements a service discovery mechanism for your multiple Quarkus applications running in dev mode to share a single server.

| Dev Services for Redis starts the container with the `quarkus-dev-service-redis` label which is used to identify the container.

If you need multiple (shared) servers, you can configure the `quarkus.redis.devservices.service-name` attribute and indicate the server name. It looks for a container with the same value, or starts a new one if none can be found. The default service name is `redis`.

Sharing is enabled by default in dev mode, but disabled in test mode. You can disable the sharing with `quarkus.redis.devservices.shared=false`.