Introduction to Docker-Compose
Docker-Compose is used to manage your containers, kind of like a container steward. We write a file, declare the container to be started in this file, configure some parameters, execute this file, Docker will start all containers according to the declared configuration.
Here is an example to build a multi-container Apache Spark cluster using docker-compose.
(1) Create a file name “Dockerfile ” and add the following contents in the file
1 |
|
(2) Build the image based on the Dockerfile and run the container
1 |
|
The following commands are used to confirm that the spark setup is working correctly
1 |
|
Based on the above configurations, a single container-based Spark framework has been created. Next step is to prepare a configuration file, compatible with docker-compose, and run a Spark cluster with at least one master node and one additional worker.
(3) Create a docker-compose.yml file and write the configuration on this file
Here, we set 1 master and 1 worker for the Spark cluster.
1 |
|
(4) Startup and shutdown of docker-compose
1 |
|
All articles in this blog adopt the CC BY-SA 4.0 agreement except for special statements. Please indicate the source for reprinting!