Customizing Docker Compose

This section covers how to customize the Docker Compose installation by editing the docker-compose.yml file.

The Docker Compose file uses Apache Kafka for the messaging middleware and Prometheus for monitoring. If you want to use RabbitMQ or InfluxDB instead, this guide shows you the changes to make in the docker compose file.

Also, when doing development of custom applications, you need to enable the Docker container that runs the Data Flow Server to see your local file system. This guide shows you how to do that as well.

Using RabbitMQ Instead of Kafka

You can use RabbitMQ rather than Kafka for communication. To do so:

  1. Delete the following configuration under the services: section:

     image: confluentinc/cp-kafka:5.2.1
     image: confluentinc/cp-zookeeper:5.2.1
  2. Insert the following:

     image: rabbitmq:3.7
       - '5672'
  3. In the dataflow-server services configuration block, add the following environment entry:

  4. Delete the following:

     - kafka
  5. Insert the following:

     - rabbitmq
  6. Modify the app-import service definition command attribute to replace with

Using InfluxDB Instead of Prometheus

You can use InfluxDB rather than Prometheus to monitor time-series database. To do so:

  1. Delete the following configuration under the services section:

     image: springcloud/spring-cloud-dataflow-prometheus-local:${DATAFLOW_VERSION:?DATAFLOW_VERSION is not set! Use 'export DATAFLOW_VERSION=dataflow-version'}
     container_name: 'prometheus'
       - 'scdf-targets:/etc/prometheus/'
       - '9090:9090'
       - service-discovery
     image: springcloud/spring-cloud-dataflow-prometheus-service-discovery:0.0.3
     container_name: 'service-discovery'
       - 'scdf-targets:/tmp/scdf-targets/'
       - '8181'
       - '8181:8181'
       - * * * * *
       - dataflow-server
  2. Insert the following:

     image: influxdb:1.7.4
     container_name: 'influxdb'
       - '8086:8086'
  3. In the dataflow-server services configuration block, delete the following environment entries:

  4. Insert the following:

  5. Modify the grafana service definition image attribute to replace spring-cloud-dataflow-grafana-prometheus with spring-cloud-dataflow-grafana-influxdb.

Accessing the Host File System

If you develop custom applications on your local machine, you need to register them with Spring Cloud Data Flow. Since Spring Cloud Data Flow runs inside of a Docker container, you need to configure the Docker container to access to your local file system to resolve the registration reference.

You can enable local disk access from Docker container by running the Spring Cloud Data Flow Server. To do so:

  1. Mount the source host folders to the dataflow-server container. For example, if the my-app.jar is in the /thing1/thing2/apps folder on your host machine, add the following volumes block to the dataflow-server service definition:

     image: springcloud/spring-cloud-dataflow-server:${DATAFLOW_VERSION}
     container_name: dataflow-server
       - '9393:9393'
       - /thing1/thing2/apps:/root/apps

This configuration provides access to the /thing1/thing2/apps directory that contains your my-app.jar from within container’s /root/apps/ folder. See the compose-file reference for further configuration details.

Volume Mounting

The explicit volume mounting couples docker-compose to your host’s file system, limiting the portability to other machines and operating systems. Unlike docker, docker-compose does not allow volume mounting from the command line (for example, there is no -v parameter). Instead, you can define a placeholder environment variable (such as HOST_APP_FOLDER) in place of the hardcoded path by using - ${HOST_APP_FOLDER}:/root/apps and setting this variable before starting docker-compose.

Once you mount the host folder, you can register the app starters (from /root/apps), with the Data Flow Shell or Dashboard by using the file:// URI schema. The following example shows how to do so:

app register --type source --name my-app --uri file://root/apps/my-app-1.0.0.RELEASE.jar

Metadata URIs

You also need to use --metadata-uri if the metadata jar is available in the /root/apps folder.

To access the host’s local maven repository from within the dataflow-server container, you must mount the host maven local repository (defaults to ~/.m2 for OSX and Linux and C:\Documents and Settings\{your-username}\.m2 for Windows) to a dataflow-server volume called /root/.m2/. For MacOS or Linux host machines, this looks like the following listing:

    - ~/.m2:/root/.m2

Now you can use the maven:// URI schema and Maven coordinates to resolve jars installed in the host’s maven repository, as the following example shows:

app register --type processor --name pose-estimation --uri maven:// --metadata-uri maven://

This approach lets you share jars that are built and installed on the host machine (for example, by using mvn clean install) directly with the dataflow-server container.

You can also pre-register the apps directly in the docker-compose instance. For every pre-registered app starer, add an additional wget statement to the app-import block configuration, as the following example shows:

  image: alpine:3.7
  command: >
    /bin/sh -c "
      wget -qO- 'https://dataflow-server:9393/apps/source/my-app' --post-data='uri=file:/root/apps/my-app.jar&metadata-uri=file:/root/apps/my-app-metadata.jar';
      echo 'My custom apps imported'"

See the Data Flow REST API for further details.