I've been trying to pull in a private (custom) MySQL image from my Docker Hub repository to the gitlab-ci.yml pipeline as a service. I have added a before_script that tries to log in to dockerhub with my username and password (CI variables). There's no output in the failed build log suggesting whether the login to Docker Hub was successful or otherwise but I'm assuming not because the pulling of my image fails with the following message (edit: or it's never even attempted because gitlab tries to get the services before it runs the before script?):
repository does not exist or may require 'docker login' (executor_docker.go:168:0s)
I am using a shared runner (because I believe that's my only option using gitlab.com?) I've seen quite a few mentions of the gitlab ci token for docker but I've found no documentation explaining how to facilitate this.
I'm sure I'm just overlooking something/not understanding or coming across the appropriate solution in my searches so apologies if I'm just being inexperienced and thanks in advance for any help.
My gitlab-ci (the maven variables are because this project's build has a dependency on a private maven repo. The database and redis host variables are injected into my app at runtime so they know which container to point to)
image: maven:3.5.0-jdk-8
before_script:
- "docker login -u$DOCKER_USER -p$DOCKER_PASS" #pipeline variables
variables:
MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
DATABASE_HOST: mysql
REDIS_HOST: redis
services:
- name: privaterepo/private-mysql-schema
alias: mysql
- name: redis:latest
alias: redis
stages:
- build
maven-build:
stage: build
script: "mvn $MAVEN_CLI_OPTS package -B"
artifacts:
paths:
- target/*.jar
