What’s the story of Docker Compose under Docker 1.12.1 “Swarm Mode”?

What’s the story of Docker compose in 1.12.1 Swarm Mode? How does it integrates with the new APIs – service, node and swarm? How compose will handle containers or services in swarm mode?Is the newer docker compose still limited to spawning individual containers and Docker engine takes care of just scheduling all the jobs/tasks in a single host? What is all about Docker Stack & Distributed Application Bundle? – Let us spend some time in understanding what is the state of Docker compose in terms of newer Docker 1.12.1 Swarm Mode.

Docker Compose is a “tool for defining and running your multi-container Docker applications”. Your applications can be defined in a YAML file where all the options that you used in `docker run` are now defined. Compose also allows you to manage your application as a single entity rather than dealing with individual containers.

Speaking in terms of Docker 1.12.1, Docker compose is a tool for defining, launching, and managing services, where a service is defined as one or more replicas of a Docker container. Services and systems of services are defined in YAML files  and managed with docker-compose command.Compose allows you to accomplish tasks like building docker images, launching containerized applications as services, scaling services up or down and viewing logs for the collection of containers making a service.

Que: Does Docker compose support Swarm Mode under Docker 1.12.1?

The answer is YES. This is achieved using bundle file which is still in experimental phase and mightn’t support all the features like volume, constraints etc.

Que: Can I use docker-compose files to start services under 1.12 release?

The answer is Yes, you can.

It is two step process.

  1. First one need to create a bundle file from docker-compose.yml using `docker-compose bundle`  command( having .dab extension) and then,
  2. Create an application stack from the bundle file using `docker deploy` command.( don’t specify .dab extension

Let us understand the two new concept which Docker Team introduced to start services –

  1. Distributed Application Bundle (DAB)
  2. Docker Stacks

Please remember that these features are experimental under Docker 1.12 and Compose 1.8. Please note that neither Docker Engine nor the Docker Registry support distribution of bundles as of today.

What is Distributed Application Bundle?

The Distributed Application Bundle (DAB) helps developers to build and test containerized apps and then wrap all the app artifacts into stable .dab files. Operation teams, in turn, can take those .dab  to deploy apps by creating stacks of services from DABs.

To understand clearly what DAB is – let us understand a simple analogy (shown below).


Using Dockerfile, we usually build images and then we create containers from that built image. In short, Image is a portable format for a single container.In the same way, a docker-compose.yml can be built into a distributed application bundle, and stacks can be created from that bundle as shown above.

Bundles are a multi-image redistributable format that describe multi-container distributed applications (or stacks) running on Docker. A bundle is akin to a “multi-image image,” and deploying it gives rise to a “stack” consisting of several communicating microservices. Conceptually, this is analogous to Docker images today.

Creating a Distributed Application Bundle?

As of Docker 1.12, docker-compose is currently the tool used to create bundle files. A bundle file is generated from a Compose v2 file using docker-compose bundle [-f docker-compose.yml]. It is then deployed using the docker deploy sub-command: docker deploy --file ownstack.dab. Let us try hands on creating a simple DAB for wordpress application.


Please remember that docker deploy command is NOT available under the final 1.12.1 release. You need to pull the experimental branch to test it out

I ensured that I have the latest 1.12.2 experimental release installed on my system.


Let us first install docker-compose 1.8 through the below command sequence:

node1:~$ sudo -i

root@node1:~# curl -L https://github.com/docker/compose/releases/download/1.8.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose


root@node1:~# exit


node1:~$ sudo chmod +x /usr/local/bin/docker-compose

node1:~$ sudo docker-compose –version

docker-compose version 1.8.0, build f3628c7

I assume that Swarm Mode cluster is up and running. I have 4 node cluster running with 1 master node and 3 worker nodes as shown below:


So, we have newer docker-compose installed on our system. Let us create a docker-compose.yml for wordpress application as shown below:


Let’s create a bundle file using the below command:

$sudo docker-compose bundle -o collabnix.dab

this command builds .dab file which holds the following contents:


Creating a stack from DAB

Now, it’s time to use docker deploy command to start the services:


Done. Verify that your services are up and running under Swarm Mode:



Hence, we saw how docker-compose can run the services under Swarm Mode using two step process – using DAB and then followed by `docker deploy`.

Please note that Swarm assigns a random port to the service, hence one need to manually update it using docker service update command.

Que: Does DAB support volume creation, constraints etc?

The answer is NO.

As of Docker 1.12.1,  DAB file does not support options like volume, constraints etc. In case you want to use volume, the only way is using the --mount flag under `docker service` command.

For example, to use NFS mount, one can run the specific command:

$sudo docker service create  –mount type=volume,volume-opt=o=addr=<source-host which can be master node>, volume-opt=device=:<NFS directory>,volume-opt=type=nfs,source=<volume name>, target=/<insideContainer> –replicas 3 –name <service-name> dockerimage <command>

Que: What’s the future plan for DAB? Will docker-compose be the only way to generate bundle files?

As per the latest updates, Docker Team has started working on a new docker bundle sub-command which will help generate bundles from Compose V2 input files.

docker bundle build [-f COMPOSE_FILE] -t BUNDLE

In addition, Docker will move toward a system in which bundles are stored and managed internally by the Engine rather than as user-managed .dab files. To know further, refer this link.

Kudos to Docker Team for introducing DAB for developers to build and test containerized apps & Docker Stack for operation teams to create stack of numerous services. With Docker 1.12, developers and ops now share a set of simple and powerful APIs, tools, and formats for building the software.

One thought on “What’s the story of Docker Compose under Docker 1.12.1 “Swarm Mode”?

Leave a Reply

Your email address will not be published. Required fields are marked *