Docker compose script to set up the development environment
Now that we have set up both Tomcat and MySQL as individual containers, let's create a Docker compose script using which both the containers can be started simultaneously, thereby, starting the Dev environment.
Save the following source code as docker-compose.yml in the same folder as the aforementioned files:
Execute the following command to start and stop the services:
// For starting the services in the foreground
docker-compose up
// For starting the services in the background (detached mode)
docker-compose up -d
// For stopping the services
docker-compose stop
Test whether both the default Tomcat web app and MySQL server can be accessed. Access the URL 192.168.99.100:8080, and make sure that the web page as shown in Figure 1.20 is displayed. Also, open MySQL Workbench and access the MySQL server at IP 192.168.99.100 and port 3326 (as specified in the preceding docker-compose.yml file).