piotrek piotrek - 4 months ago 56
Java Question

running docker from gradle: cannot pull image

i have no problems running docker from cmd line:

docker run -p 5432:5432 -it --rm postgres:9.5.2`

but when i do it from gradle, using dcompose plugin, i got

Could not evaluate onlyIf predicate for task ':pullDatabaseImage'.
> Docker command failed: Certificate path (DOCKER_CERT_PATH) '/home/xxx/.docker/certs' doesn't exist.

my config:

plugins {
id "com.chrisgahlert.gradle-dcompose-plugin" version "0.3.2"

dcompose {
database {
image = 'postgres:9.5.2' // Required

test {
dependsOn startDatabaseContainer
finalizedBy removeDatabaseContainer

what's wrong? how can i run docker from gradle?


I found that docker uses Unix sockets for unsecured local communication but it requires custom certificates for network communication / IP sockets. plugin com.chrisgahlert.gradle-dcompose-plugin uses network communication, so there is no way to make it work out of the box (every developer that wants to run it locally would have to configure his docker). So I stopped using that plugin and switched to manually executing system command (docker run ...) from Java. This way no additional security configuration is needed.