Connection reset by peer inside dind containers

Problem to solve

My tests have stopped working today in GitlabCI without making any code changes. The tests are using a database which is running in a Docker container (through testcontainers).
The Docker container and the DB running inside it are starting just fine:

waiting for server to start....2024-05-09 13:54:16.504 UTC [35] LOG:  starting PostgreSQL 12.18 on x86_64-pc-linux-musl, compiled by gcc (Alpine 13.2.1_git20231014) 13.2.1 20231014, 64-bit
2024-05-09 13:54:16.506 UTC [35] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2024-05-09 13:54:16.531 UTC [35] LOG:  database system is ready to accept connections

The error I’m getting back is

read tcp [fd76:1234:1234:1:0:242:ac44:4]:33592->[fd76:1234:1234:1:0:242:ac44:3]:32768: read: connection reset by peer

This error is being returned when trying to ping the database from the code.

Steps to reproduce

I’ve tried different dind versions, various testcontainers versions.
Please note that the tests are running locally (outside GitlabCI) and they were running fine in Gitlab CI up until today. No code change was made so this issue comes from Gitlab CI. If I rerun a previously successful job, it now fails.


  - name: docker:dind

  DOCKER_HOST: "tcp://docker:2375"
  DOCKER_DRIVER: overlay2

Versions SaaS



in your .gitlab-ci.yml fixes the problem as instructed by Error: connect EHOSTUNREACH using postgres as a service (#218) · Issues · / Ops Sub-Department / shared-runners / infrastructure · GitLab

1 Like