O'Reilly logo

Docker: Creating Structured Containers by Scott Gallagher, Allan Espinosa, Russ McKendrick, Santosh Kumar Konduri, Vaibhav Kohli, Rajdeep Dua, Neependra Khare, Oskar Hane, Shrikrishna Holla, Vinod Singh, Jeeva S. Chelladhurai, Pethuru Raj

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Docker Compose – examples

In this section, we will take a look at some examples and break them to understand what we can do within the docker-compose.yml file. Remember, earlier we discussed that in the YAML file, there needs to be either an image section or a build section. Let's take a look at an example using each. Then, we will look at an example using as many of the options available for the Docker Compose YAML file as possible.

Here is a breakdown of an example docker-compose.yml file. We will break the contents into sections to help you understand each entry.

image

The image section tells Docker Compose that you are going to define the configuration of your containers and what settings each will have:

haproxy:#container name
 image: tutum/haproxy ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required