:composeUp is not idempotent with manual docker-compose up -d
gorodum opened this issue · comments
Hi there,
I have a docker-compose file including mysql, redis and kafka
also i have a gradle-docker-compose-plugin for running it within tests
For some reason (speed up actually) I want to lunch docker-compose up -d over the same file once manually on local machine
I'm expecting that plugin will noticed that containers are up and running and gracefully pass execution to my tests
BUT: Instead i have Exit-code 1 when calling docker-compose, stdout: N/A
and have to comment line in gradle.build manually as workaround
I consider that is nothing but misbehaviour of the plugin because docker-compose up -d
is fully idempotent i can run it as many times as i want
Thank you.
Hello,
regarding reconnecting to existing containers: Docker Compose has a concept of Project. When calling docker-compose up
manually, it can be specified using -p
or --project-name
: https://docs.docker.com/compose/reference/
If it is not specified then it fallbacks to the sanitized directory name.
This plugin allows you to set this parameter via projectName
property. So if you set these values to the same value, it should hopefully work (~docker-compose
executed by this plugin will be aware of the manually executed docker-compose
).
Thanks for the rapid answer
I tried this approach, but it seems it is not enough
my-env-db-1 health state reported as 'healthy' - continuing...
Probing TCP socket on localhost:3308 of 'my-env-db-1'
TCP socket on localhost:3308 of 'my-env-db-1' is ready
Probing TCP socket on localhost:2181 of 'my-env-kafka-1'
TCP socket on localhost:2181 of 'my-env-kafka-1' is ready
Probing TCP socket on localhost:9092 of 'my-env-kafka-1'
and than it seems failing with infinite check
Will use localhost as host of kafka
Waiting for TCP socket on localhost:9092 of 'my-env-kafka-1' (TCP connection on localhost:9092 of 'my-env-kafka-1' was disconnected right after connected)
Hello, this error is typical if you expose a port (9092
in this case), but the application doesn't open it.
In fact it does, if i set waitForTcpPorts
to false
, it will be working fine, But i don't understand and don't like this workaround tbh.
Do you have a normal solution for it? may be some approaches to give a try
It looks like you expose port 9092
on the container, but the container doesn't open this port. If you don't want to wait for the port, remove it from the exposed ports from the docker-compose.yml
.