Docker Compose is a tool for defining and running multi-container Docker applications. It allows you to define all the services, networks, and volumes for your application in a single docker-compose.yml file, making it easier to manage and deploy complex applications with multiple components.
Download and install docker desktop
Follow the steps provided in the docker docs to install and setup docker desktop docs.docker.com
Some key concepts and features of docker compose:
- Services
- Networks
- Volumes
- Environment Variables
- Scaling
Lets create a sample docker-compose which will build containers from the images available for order application and products application. Lets create a network between then too. Expose them on their individual ports.
Lets run the docker compose up command and hit order application’s endpoint:
Now lets see in the docker desktop how our containers are looking:
docker-compose up, runs the container in interactive mode. We can run them in detached mode by adding -d at the end of the docker-compose up command:
We can stop the running containers that are defined in our Docker Compose configuration using command:
docker-compose stop
You can also pass the command to build an image from Dockerfile path in your docker-compose file: