In the Docker Compose file, you can define it to compose a set of containers. This is a YAML configuration file. docker-compose manages runtime configuration of the containers with the right options and configuration. We have created a docker-compose.yml file in the preceding section. Let's test the configuration of this file for syntax errors by using the following command:
$ docker-compose config
You can see the following output:
In the case of a syntax error, it renders as the following:
Finally, we can start it with one command:
$ docker-compose up -d
Let's see the output of the preceding command:
The preceding command is running containers in the detached mode because of the -d option. Let's check the container's status using the following command:
$ docker-compose ps
It renders the following output:
As you can see, the service containers are running successfully; we can test it by accessing the following URLs in the browser.
Let's first test account-service by using the http://192.168.99.100:8181/account/101 URL. It renders data as follows:
Let's test the customer-service by using the http://192.168.99.100:8282/customer/1001 URL. It renders data as follows:
Let's stop the services from running by using the following command:
$ docker-compose down
Let's see the following output:
As you can see, all containers have been stopped.