To run it, open a command line and navigate to the same directory as the docker-compose.yml file. It also specifies the password, which you wouldn’t want to do in a real world situation. There’s a lot of details in there but basically you can see that it specifies the images to be used, the service names, the ports available, and networks the different services are on. To try it out, open a text editor and paste the text from this file. Docker Compose handles service discovery directly, allowing the app to reference the service directly and Docker will route traffic to the right container.
We’ve pushed two images to the Docker Hub under the dockersamples repo. You can check out the app in our dockersamples GitHub repo.
This sample uses a simple Java web app running in Tomcat with a MySQL database. Docker Compose installs automatically with Docker Desktop.Ī multi-container app is an app that has multiple containers running and communicating with each other. Then, with a single command, you create and start all the services from your configuration. With Compose, you use a YAML file to configure your application’s services. Easily connect multiple services togetherĭocker Compose is a tool for defining and running multi-container Docker applications.