testcontainers / testcontainers/testcontainers-php

Error when connecting to docker-rootless socket via tcp

Open
#57 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
215
Forks
34
Avg merge
1h 59m
Merged PRs (30d)
3

Description

When running testcontainers in GitLab CI with dind-rootless service, it does not work when connecting via tcp.

It works with dind (rootful):

.gitlab-ci.yml:

test:
  stage: test
  image: php:8.3-cli
  services:
    - docker:29-dind
  variables:
    DOCKER_HOST: tcp://docker:2375
    DOCKER_TLS_CERTDIR: ""

Doesn't work with dind-rootless (Exact same setup works with testcontainers-dotnet)

.gitlab-ci.yml:

test:
  stage: test
  image: php:8.3-cli
  services:
    - docker:29-dind-rootless
  variables:
    DOCKER_HOST: tcp://docker:2375
    DOCKER_TLS_CERTDIR: ""
    TESTCONTAINERS_RYUK_DISABLED: true

This is the error:
1) Exception in third-party event subscriber: Cannot read the response
#0 /builds/group/project/vendor/php-http/socket-client/src/Client.php(85): Http\Client\Socket\Client->readResponse()
#1 /builds/group/project/vendor/php-http/client-common/src/HttpClientDecorator.php(28): Http\Client\Socket\Client->sendRequest()

It works when binding the dind docker socket though:

.gitlab-ci.yml:

test-php:
  stage: test
  image: php:8.3-cli
  services:
    - name: docker:29-dind-rootless
  variables:
    DOCKER_HOST: "unix:///runner/services/docker/docker.sock"
    TESTCONTAINERS_RYUK_DISABLED: true
    TESTCONTAINERS_HOST_OVERRIDE: docker

In /etc/gitlab-runner/config.toml
volumes = ["/runner/services/docker", "/cache"]

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the two configurations in .gitlab-ci.yml, starting with the TCP setup and the stack trace at vendor/php-http/socket-client/src/Client.php:85. Compare it with the working Unix-socket setup and /etc/gitlab-runner/config.toml; done means dind-rootless works through TCP without the reported Cannot read the response error.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, gitlab, php
Domain
infrastructure, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.