Skip to content
extr3m0 edited this page Oct 7, 2016 · 5 revisions

To apply the plugin, see the Gradle plugin page: https://plugins.gradle.org/plugin/com.chrisgahlert.gradle-dcompose-plugin

When running the build, you will need to make sure, Docker is properly configured. The easiest way is to just use environment variables. The plugin will automatically look for the following Docker environment variables:

  • DOCKER_HOST (e.g. tcp://localhost:2376)
  • DOCKER_TLS_VERIFY (e.g. 0)
  • DOCKER_CERT_PATH

You can easily set these variables with the help of this shell script (when using docker-machine): eval "$(docker-machine env default)"

In order to customise the Docker Client configuration programmatically, you can include the following configuration in your build script:

dcompose {
  dockerClientConfig = {
    // Will delegate to the Builder from
    // https://github.com/docker-java/docker-java/blob/master/src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java#L317
    withDockerHost 'tcp://somehost:1234'
    withTlsVerify false
  }
}

The evaluation order of properties will be (in descending order of precedence):

  1. The dockerClientConfig closure
  2. System properties (e.g. gradle startSomeContainer -DDOCKER_HOST=tcp://somehost:1234)
  3. Environment variables (e.g. export DOCKER_HOST=tcp://somehost:1234; gradle startSomeContainer
  4. A properties file in $HOME/.docker-java.properties

For a complete documentation see the configuration options of the docker-java project: https://github.com/docker-java/docker-java#documentation

Please also make sure, that the Project has the Maven Central Repository or a mirror added. This is needed to download the Docker Java Client dependencies.

After applying the plugin you can start by defining services.