Compose 1.6: New Compose file for defining networks and volumes

Aanand Prasad

Feb 04 2016

In the previous version of Docker Engine we added a completely new system for managing networks and volumes, and we’re pleased to announce full support for these features in Docker Compose.

Compose files used to describe just one thing: the services that make up your distributed application. We’ve now added networks and volumes to the mix, allowing you to describe much more complex applications. You can set up your app on your development machine with multiple network tiers and complex storage configurations, replicating how you might set it up in production. You can then take that same configuration from development, and use it to run your app on CI, on staging, and right through into production.


We’ve implemented this by making networks and volumes top-level objects in Compose files. Everything that used to be in a Compose file is now under a new services key.

To get an idea of the power that this new format gives you, take a look at this example application with multiple network tiers and volumes stored in Flocker:

version: "2"

    image: myapp
      - front
      - back
    image: redis
      - redis-data:/var/lib/redis
      - back

    driver: flocker

    driver: overlay
    driver: overlay


Hopefully this sparks your imagination as to what is now possible! Check out this GitHub repository for a full example that you can try out.

It’s really easy to convert your existing applications to the new format. It’s mostly a case of adding the lines version: “2” and services: to the top of your file, but there are a few caveats, so check out these instructions if you run into issues. If you’re not quite ready to make the jump yet, that’s fine – Compose 1.6 still works just fine with the old format.

As well as the new Compose file, there are also a couple of other new things in this release:

  • Set up development environments much faster: At the same time as specifying a build directory such as build: ./code, you can also specify an image such as image: myusername/webapp. This means that you can use either docker-compose build to build the image, or make it faster by using docker-compose pull to pull it from a registry. You can thus use pre-built images to get a development environment running faster, instead of waiting for images to build locally.
  • docker-compose events: A new command that streams the Engine events for your application, which can be used as a building block for tools which react to events such as containers starting and stopping.
  • Build arguments: You can now pass arguments to builds from your Compose file.

Check out the release notes for a full list of what’s new. To install or upgrade Compose, the easiest way is to download Docker Toolbox.

To read more about running Compose in production, there is a guide available in the documentation.

Watch this video on the new version of Docker Compose files

Additional Resources on Docker 1.10


Learn More about Docker


7 thoughts on “Compose 1.6: New Compose file for defining networks and volumes

  1. Still no way to have a service be fully available before starting another one?

    • There’s a long discussion here about why that’s a bigger problem than it seems, and not one that Compose should necessarily solve:

      We’re working on improving the documentation so as to better explain the best practices around it.

    • We circumvented this by letting the services wait that depends upon the run up of another. Quite often you have a fast spun up web application and a slower starting database where this is a real problem.

    • So, perhaps a more general question for a somewhat newbie: From reading it seems there are 2 different requirements for production disk space. I understand -v (i.e. volume for local/on-docker-container or for having an independent VM with storage); however, I am I correct that if I want to use a SAN I need to Flocker or a similar plug-in?

      Secondly, I have seen docker, when thrashing, fill disk space. What is the common approach to handling this event. Is it to monitor the space and clear the "zombie container" on event?

  2. Hi,

    I’m really excited about new “network-scoped alias” feature. But, how I can create this within a docker-compose file?

  3. Avatar

    Richard Ahlquist


    Do you know of any sources of good examples of V2 syntax involving assigning static host IP addresses to individual containers?


Leave a Reply