2019-09-04 21:01:54 +05:30
---
2020-06-23 00:09:42 +05:30
stage: Verify
group: Runner
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#designated-technical-writers
2019-09-04 21:01:54 +05:30
type: reference
---
2015-12-23 02:04:40 +05:30
# Using Redis
As many applications depend on Redis as their key-value store, you will
eventually need it in order for your tests to run. Below you are guided how to
do this with the Docker and Shell executors of GitLab Runner.
## Use Redis with the Docker executor
If you are using [GitLab Runner ](../runners/README.md ) with the Docker executor
you basically have everything set up already.
First, in your `.gitlab-ci.yml` add:
```yaml
services:
- redis:latest
```
Then you need to configure your application to use the Redis database, for
example:
```yaml
Host: redis
```
And that's it. Redis will now be available to be used within your testing
framework.
2020-06-23 00:09:42 +05:30
You can also use any other Docker image available on [Docker Hub ](https://hub.docker.com/_/redis ).
2015-12-23 02:04:40 +05:30
For example, to use Redis 2.8 the service becomes `redis:2.8` .
## Use Redis with the Shell executor
Redis can also be used on manually configured servers that are using GitLab
Runner with the Shell executor.
In your build machine install the Redis server:
2020-03-13 15:44:24 +05:30
```shell
2015-12-23 02:04:40 +05:30
sudo apt-get install redis-server
```
Verify that you can connect to the server with the `gitlab-runner` user:
2020-03-13 15:44:24 +05:30
```shell
2019-02-15 15:39:39 +05:30
# Try connecting the Redis server
2015-12-23 02:04:40 +05:30
sudo -u gitlab-runner -H redis-cli
# Quit the session
127.0.0.1:6379> quit
```
Finally, configure your application to use the database, for example:
```yaml
Host: localhost
```
## Example project
2019-12-21 20:55:43 +05:30
We have set up an [Example Redis Project ](https://gitlab.com/gitlab-examples/redis ) for your convenience
2015-12-23 02:04:40 +05:30
that runs on [GitLab.com ](https://gitlab.com ) using our publicly available
[shared runners ](../runners/README.md ).
2020-04-08 14:13:33 +05:30
Want to hack on it? Simply fork it, commit and push your changes. Within a few
2017-08-17 22:00:37 +05:30
moments the changes will be picked by a public runner and the job will begin.