Running Integrationtest with MariaDB as Service: Errno -2] Name does not resolve

Hello everyone,

I’m building a integration test pipeline where I use MariaDB. After reading the GitLab CI/CD documentation I found the

service:

  • mariadb:latest

definition for the GitLab CI to include the mariadb image and connect to the database. Regarding the documentation the host is mysql (Link)

But when I try to connect to the database I get the errror [Errno -2] Name does not resolve)

Part of the gitlab-ci.yml looks like this:

image: python:alpine
environment:
  name: integration
services:
  - mariadb:latest
variables:
  MYSQL_DATABASE: test_database
  MYSQL_ROOT_PASSWORD: root_password
  DATABASE_URI_DEV: mysql+pymysql://test_user:password@mysql:3306/test_database
  MYSQL_USER: test_user
  MYSQL_PASSWORD: password

DATABASE_URI_DEV is the connection string that I use to establish the connection via SQLAlchemy.

It also doesn’t work without the port at the end. I tried it with localhost but then I get a connection refused error.

I really appreciate your help :slight_smile:

Edit: Provided more of my gitlab-ci.yml

Hello,

In this context the name of the host your python container is mariadb so your DATABASE_URI_DEV should be updated to:
DATABASE_URI_DEV: mysql+pymysql://test_user:password@mariadb:3306/test_database

Regards.
Romain.