gradle-docker-compose-plugin icon indicating copy to clipboard operation
gradle-docker-compose-plugin copied to clipboard

Add captureContainersOutput per service

Open mitasov-ra opened this issue 1 year ago • 1 comments

captureContainersOutput is very useful, but when I have docker-compose with up to 10 services, this switch simply explodes my console.

I think it would be nice to have option to enable containers output only for specified services, not for all at once.

Right now I deal with this problem by controlling log levels for each container individually, but this is really time consuming

mitasov-ra avatar Mar 22 '24 09:03 mitasov-ra

was just looking for the same feature and found this +1

A possible workaround that I am using is splitting services into two files and then making them dependent: I only need output from the main compose


// https://githu b.com/avast/gradle-docker-compose-plugin
dockerCompose {
	infra {
			useComposeFiles = ['docker-compose-infra.yml']
			dockerComposeWorkingDirectory = project.file('docker')
			buildAdditionalArgs = ['--force-rm']
	}
	main{
			useComposeFiles = ['docker-compose-main.yml']
			dockerComposeWorkingDirectory = project.file('docker')
			buildAdditionalArgs = ['--force-rm']
			captureContainersOutput = true
	}
}
mainComposeUp.dependsOn ear, infraComposeUp

This also has the advantage that I can do gradle mainComposeDown without having to stop my other services which are unchanged.

You can then use an external network both compose files to ensure containers "see" each other:

networks:
  dev-network:
    external: true
services:
  db-svr: 
    image: mariadb:lts-jammy
    networks:
    - dev-network

turchinc avatar Apr 17 '24 16:04 turchinc