While developing and debugging a project, you may find the need to run and connect to a microservice, for example, using a client. Readily available Docker images, like the ones we made in the previous steps, are quite handy in such situations.
To run our service, we’ll be using the scenario we wrote in the third step of this tutorial in the docker-compose.yml file:
To automated the running process, we can create a file named run.ps1 with the following script:
To run the script, enter the following command:
While running, the script will generate a name for the image using the data in the component.json file and then run it in Docker Compose. In accordance with the scenario, Docker Compose will run two containers: one with the service, and another with a DB. The service will be made available on port 8080.
When the service is stopped, both containers will automatically be stopped as well.
Congratulations! You now know how to Dockerize your microservices! We hope this knowledge helps you avoid environment related errors and keep your development process automated and standardized.