How to use redis dockerhub as a service in Gitlab CI .gitlab-ci.yml?

Viewed 753

My .gitlab-ci.yml is this:

image: "python:3.5"

services:
  - redis:4.0.2
  - mongo:3.4.10

stages:
  - checkEverythingRuns

checkEverythingRuns:
  stage: checkEverythingRuns 
  script: 
    - "python --version"
    - "pip --version"
    - "redis-server -v"
    - "mongod --version"

The redis image downloads correctly:

Using docker image redis:4.0.2 ID=sha256:blablabla

But it throws the next error:

$ redis-server -v
/bin/bash: line 14: redis-server: command not found
ERROR: Job failed: exit code 1
1 Answers

The redis-server command is not found on the image you are running your job in: python:3.5. The redis server is a container auto-linked to your job-container, python:3.5.

You could install redis-tools with apt-get install redis-tools and then run:

redis-cli -h redis ping

redis is the default hostname your service gets, if you want to change it take a look here to specify a service alias.

Related