Hello,
I am using own runner with a docker executor. I am using the following example .gitlab-ci.yml:
image: docker:20.10.16
variables:
DOCKER_TLS_CERTDIR: "/certs"
DB_HOST: host10.com
DB_PORT: 3306
DB_NAME: db1
DB_USER: user1
DB_PASSWORD: somepassword
services:
- docker:20.10.16-dind
before_script:
- docker info
build:
stage: build
tags:
- master
script:
- docker build -t my-docker-image .
- docker run -p "80:8080" my-docker-image
How can I pass the variables above to the container from the runner host itself? I’ve tried adding them to /etc/gitlab-runner/config.toml like this:
[[runners]]
name = "Runner 1.."
.......
[runners.docker]
tls_verify = false
image = "docker:stable"
............
shm_size = 0
environment = ["DOCKER_TLS_CERTDIR=/certs", "DB_HOST=host10.com", "DB_PORT=3306", "DB_NAME=db1", "DB_USER=user1", "DB_PASSWORD=somepassword"]
But it does not seem to work, the application running inside docker executor does not see them. Am I doing something wrong? I want that they are taken somehow from the runner host itself, instead of letting passwords and other info into .gitlab-ci.yml. Any suggestions please?
Ps: I am using docker version 23.0.1 and gitlab runner 15.9.1 on Ubuntu 22.04.
Thank you,
Dragos