Gitlab CI, docker:dind service SQLSTATE[HY000] [2002] Connection refused

I’ve a self hosted gitlab runner,
I want to run unit tests in runner and I’ve a database container dump in aws s3 that I want to use while running unit tests.
Locally unit-tests and same database setup is working.
so,

  • I’m running runner with custom image with php, docker, awscli and other installed
  • I’m using service docker:dind to have container where I can load my database image dump
  • I downloaded & loaded the db docker image dump to service container
  • I run the container
  • But I get error as below while connecting to mysql
  [PDOException]                             
  SQLSTATE[HY000] [2002] Connection refused  
#sectet.yml (php symfony)
  database:
    main:
      dsn: "mysql:host=dev.dev;port=3308;dbname=******"
      username: "*****"
      password: "*********"
      driver_options:
        1002: "SET NAMES UTF8"
#.gitlab-ci.yml

default:
  image: $CI_REGISTRY/bitcoin/docker-php-builds/php-fpm-ubuntu:8.1

stages:
  - install
  - lint
  - build
  - test

variables:
  FF_NETWORK_PER_BUILD: true
  CI_DEBUG_SERVICES: "true"
  CI_DEBUG_TRACE: "true"
  MYSQL_USER: "gkrw" # not possible to configure in variable because of length < 8
  DOCKER_HOST: tcp://dev.dev:2375
  DOCKER_DRIVER: overlay2  #required for DinD to work in GitLab CI
  DOCKER_TLS_CERTDIR: ""

services:
  - name: docker:dind
    alias: dev.dev

cache: &global_cache
  key:
    files:
      - composer.lock
      - ${DB_BACKUP_FILE_NAME}
  policy: pull-push

install-dependencies:
  stage: install
  rules:
    - if: $CI_COMMIT_BRANCH == "main" || $CI_PIPELINE_SOURCE == "merge_request_event"
  before_script:
    - apt-get update -yqq && apt-get install -yqq make
    - make prepare-db
  script: make install-dependencies
  cache:
    <<: *global_cache
  artifacts:
    expire_in: 1d
    paths:
      - vendor

lint-md:
  stage: lint
  rules:
    - if: $CI_COMMIT_BRANCH == "main" || $CI_PIPELINE_SOURCE == "merge_request_event"
  script: make lint-md
lint-php:
  stage: lint
  rules:
    - if: $CI_COMMIT_BRANCH == "main" || $CI_PIPELINE_SOURCE == "merge_request_event"
  script: make lint-php

build-php:
  stage: build
  rules:
    - if: $CI_COMMIT_BRANCH == "main" || $CI_PIPELINE_SOURCE == "merge_request_event"
  script: make build-php

test-db:
  stage: test
  rules:
    - if: $CI_COMMIT_BRANCH == "main" || $CI_PIPELINE_SOURCE == "merge_request_event"
  script: make test-db
test-integration:
  stage: test
  rules:
    - if: $CI_COMMIT_BRANCH == "main" || $CI_PIPELINE_SOURCE == "merge_request_event"
  script: make test-integration
test-i18nl10n:
  stage: test
  rules:
    - if: $CI_COMMIT_BRANCH == "main" || $CI_PIPELINE_SOURCE == "merge_request_event"
  script: make test-i18nl10n
test-unit:
  stage: test
  rules:
    - if: $CI_COMMIT_BRANCH == "main" || $CI_PIPELINE_SOURCE == "merge_request_event"
  script:
    - make test-unit

Makefile
.PHONY: prepare-db install install-dependencies lint lint-md lint-php build build-php test test-db test-integration test-i18nl10n test-unit

#### download dump from S3 and restore it.
prepare-db:
    # Download database backup from S3
    aws s3 cp ${DB_BACKUP_BUCKET_URL}${DB_BACKUP_FILE_NAME} ./ --only-show-errors;
    # Login to Docker registry
    docker login ${CI_REGISTRY} -u ${DOCKER_REGISTRY_USER} -p ${DOCKER_REGISTRY_PWD}
    # Load the Docker image backup
    docker load -i $(DB_BACKUP_FILE_NAME)
    # Run container from the loaded image
    docker run -d --name=phpdev-db-snap -h "dev.dev" -p 3308:3306 --restart=always -m 8GB --oom-kill-disable IMAGE_NAME

#### install
install: install-dependencies

install-dependencies:
    #Install dependencies
    composer install --no-progress
    docker logs --since=2h phpdev-db-snap
    composer init-dev-environment # HERE IT'S FAILING AS I'M CONNECTING TO DATABASE TO MAKE OPERATION

#### lint
lint: lint-md lint-php

lint-md:
    @echo lint-md

lint-php:
    @echo lint-php

#### build
build: build-php

build-php:
    @echo build-php

#### test
test: test-db test-i18nl10n test-unit test-integration

test-db:
    @echo test-db

test-integration:
    @echo test-integration

test-i18nl10n:
    @echo test-i18nl10n

test-unit:
    @echo --------- Running unit-tests ---------
    vendor/phpunit/phpunit/phpunit
    @echo --------- unit-tests finished ---------

config.toml
concurrent = 1
check_interval = 0
shutdown_timeout = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "gitlab-runner"
  url = "https://*****.de"
  id = 6
  token = "****"
  token_obtained_at = 2023-12-13T10:20:05Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "docker"
  cache_dir = "/cache"
  [runners.docker]
    tls_verify = false
    image = "alpine:latest"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache","/certs"]
    shm_size = 0
    network_mtu = 0

[[runners]]
  name = "gitlab-runner"
  url = "https://******.de"
  id = 7
  token = "****"
  token_obtained_at = 2023-12-13T10:26:46Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "docker"
  cache_dir = "/cache"
  [runners.cache]
    MaxUploadedArchiveSize = 0
  [runners.docker]
    tls_verify = false
    image = "alpine:latest"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache","/certs"]
    shm_size = 0
    network_mtu = 0

Tried same code and image dump locally which is working fine.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật