Skip to content

Wrong Service host used for connection project containers #484

@GottfriedGanssauge

Description

@GottfriedGanssauge

Issue

When running my tests with the docker-compose plugin I see the docker compose application starting, but then it stalls while probing the container ports until a timeout ends the process.

The test outputs the following messages:

> Task :change-handler:composeUp
 Network 25e428987ffd831da5b49317cd19c445_change-handler_default  Creating
 Network 25e428987ffd831da5b49317cd19c445_change-handler_default  Created
 Network 25e428987ffd831da5b49317cd19c445_change-handler_backend-unittests  Creating
 Network 25e428987ffd831da5b49317cd19c445_change-handler_backend-unittests  Created
 Container 25e428987ffd831da5b49317cd19c445_change-handler-azurestorage-1  Creating
 Container 25e428987ffd831da5b49317cd19c445_change-handler-cache-1  Creating
 Container 25e428987ffd831da5b49317cd19c445_change-handler-opensearch-1  Creating
 Container 25e428987ffd831da5b49317cd19c445_change-handler-staticfiles-1  Creating
 Container 25e428987ffd831da5b49317cd19c445_change-handler-opensearch-1  Created
 Container 25e428987ffd831da5b49317cd19c445_change-handler-azurestorage-1  Created
 Container 25e428987ffd831da5b49317cd19c445_change-handler-staticfiles-1  Created
 Container 25e428987ffd831da5b49317cd19c445_change-handler-cache-1  Created
 Container 25e428987ffd831da5b49317cd19c445_change-handler-opensearch-1  Starting
 Container 25e428987ffd831da5b49317cd19c445_change-handler-azurestorage-1  Starting
 Container 25e428987ffd831da5b49317cd19c445_change-handler-staticfiles-1  Starting
 Container 25e428987ffd831da5b49317cd19c445_change-handler-cache-1  Starting
 Container 25e428987ffd831da5b49317cd19c445_change-handler-opensearch-1  Started
 Container 25e428987ffd831da5b49317cd19c445_change-handler-cache-1  Started
 Container 25e428987ffd831da5b49317cd19c445_change-handler-staticfiles-1  Started
 Container 25e428987ffd831da5b49317cd19c445_change-handler-azurestorage-1  Started
Will use 172.20.0.1 (network 25e428987ffd831da5b49317cd19c445_change-handler_default) as host of opensearch
Will use 172.21.0.1 (network 25e428987ffd831da5b49317cd19c445_change-handler_backend-unittests) as host of staticfiles
Will use 172.21.0.1 (network 25e428987ffd831da5b49317cd19c445_change-handler_backend-unittests) as host of azurestorage
Will use 172.20.0.1 (network 25e428987ffd831da5b49317cd19c445_change-handler_default) as host of cache
Probing TCP socket on 172.20.0.1:32808 of 'opensearch-1'
Waiting for TCP socket on 172.20.0.1:32808 of 'opensearch-1' (Verbindungsaufbau abgelehnt)
Will use 172.20.0.1 (network 25e428987ffd831da5b49317cd19c445_change-handler_default) as host of opensearch
Waiting for TCP socket on 172.20.0.1:32808 of 'opensearch-1' (Verbindungsaufbau abgelehnt)
Will use 172.20.0.1 (network 25e428987ffd831da5b49317cd19c445_change-handler_default) as host of opensearch
Waiting for TCP socket on 172.20.0.1:32808 of 'opensearch-1' (Verbindungsaufbau abgelehnt)
Will use 172.20.0.1 (network 25e428987ffd831da5b49317cd19c445_change-handler_default) as host of opensearch

The containers for the project are these:

NAME                                                             IMAGE                                            COMMAND                  SERVICE        CREATED          STATUS          PORTS
25e428987ffd831da5b49317cd19c445_change-handler-azurestorage-1   mcr.microsoft.com/azure-storage/azurite:3.35.0   "docker-entrypoint.s…"   azurestorage   12 minutes ago   Up 12 minutes   127.0.0.1:32815->10000/tcp, 127.0.0.1:32816->10001/tcp, 127.0.0.1:32817->10002/tcp
25e428987ffd831da5b49317cd19c445_change-handler-cache-1          redis:7.4-alpine                                 "docker-entrypoint.s…"   cache          12 minutes ago   Up 12 minutes   127.0.0.1:32811->6379/tcp
25e428987ffd831da5b49317cd19c445_change-handler-opensearch-1     opensearchproject/opensearch:2.19.1              "./opensearch-docker…"   opensearch     12 minutes ago   Up 12 minutes   9650/tcp, 127.0.0.1:32808->9200/tcp, 127.0.0.1:32809->9300/tcp, 127.0.0.1:32810->9600/tcp
25e428987ffd831da5b49317cd19c445_change-handler-staticfiles-1    mcr.microsoft.com/azure-storage/azurite:3.35.0   "docker-entrypoint.s…"   staticfiles    12 minutes ago   Up 12 minutes   20000-20002/tcp, 127.0.0.1:32812->10000/tcp, 127.0.0.1:32813->10001/tcp, 127.0.0.1:32814->10002/tcp

As can be seen the containers all listen on localhost - but the docker-component plugin wants to connect them at their gateway address (which obviously does not work)

Setting SERVICES_HOST=127.0.0.1 makes the tests run.

On MacOS with docker desktop the correct 127.0.0.1 is used, without setting SERVICES_HOST for the same project.

I attached the docker-compose project (normalized with docker compose config) and the docker inspect output for the container involved in the log above (see below).

System environment

OS
: Linux 6.8.0-79-generic x86_64

Distribution
: Ubuntu 24.04.3 LTS

Docker
: ~~~
Client: Docker Engine - Community
Version: 28.4.0

Server: Docker Engine - Community
 Engine:
  Version:          28.4.0
 containerd:
  Version:          1.7.27
 runc:
  Version:          1.2.5
 docker-init:
  Version:          0.19.0
~~~

Docker compose
: Docker Compose version v2.39.2

gradle:
: 8.14.3

Java
: ~~~
openjdk version "21.0.8" 2025-07-15
OpenJDK Runtime Environment (build 21.0.8+9-Ubuntu-0ubuntu124.04.1)
OpenJDK 64-Bit Server VM (build 21.0.8+9-Ubuntu-0ubuntu124.04.1, mixed mode, sharing)
~~~

Attachments

docker-compose.yaml
opensearch-inspection.json

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions