An example of docker-compose to set up a single Apache Spark node connecting to MongoDB via MongoDB Connector for Hadoop
You can start by running command :
docker-compose run spark bash
Which would run the spark node and the mongodb node, and provides you with bash shell for the spark.
From the spark instance, you could reach the MongoDB instance using mongodb
hostname.
See related article: