Docker-Compose with Docker 1.12 “Swarm Mode”

Does anyone know how (if possible) to run docker-compose commands against a swarm using the new docker 1.12 ‘swarm mode’ swarm?

I know with the previous ‘Docker Swarm’ you could run docker-compose commands directly against the swarm by updating the DOCKER_HOST to point to the swarm master :
export DOCKER_HOST="tcp://"
and then simply execute commands as if you were running them against a single instance of Docker engine.

  • Path is not writable within container
  • Why connect to Google Cloud SQL failed inside Docker container but success outside Docker container?
  • Docker DNS setup on VPS
  • How to start a Docker container with cloud-config file for CoreOS?
  • Elastic Beanstalk environment variables for Docker host
  • Docker, redirecting to virtualbox port
  • OR is this functionality something that docker-compose bundle is replacing?

  • Unable to push docker image to amazon ECR
  • How to keep track of pip installed packages on one docker container to use them in another
  • Docker command with build / run / etc. “too many open files”
  • How to back up docker swarm mode service configuration for disaster recovery
  • Can't build docker package (docker-git) with makepkg
  • Adjust OOM killer for subprocess in Docker container
  • 3 Solutions collect form web for “Docker-Compose with Docker 1.12 “Swarm Mode””

    I realized my question was vaguely worded and actually has two parts to it. Eventually however, I was able to figure out solutions to both issues.

    1) Can you run commands directly ‘against’ a swarm / swarm-mode in Docker 1.12 running on a remote machine?

    While you can’t really run commands ‘against’ a swarm you CAN run docker service commands on the master node of a swarm in order to run services on that swarm.
    You can also configure the Docker daemon (the docker daemon that is the master node of the swarm) to listen on TCP ports in order to externally expose the Docker API.

    2) Can you still use docker-compose files to start services in Docker 1.12 swarm-mode?

    Yes, although these features are currently part of Docker’s “experimental” features. This means you must download/install the version that includes the experimental features (check the github).
    You essentially follow these instructions
    to go from the docker-compose.yml file to a distributed application bundle and then to an application stack (this is when your services are actually run).
    $ docker-compose bundle
    $ docker deploy [OPTIONS] STACK

    Here’s what I did:

    1. On my remote swarm manager node I started docker with the following options:

      docker daemon -D -H unix:///var/run/docker.sock -H tcp:// &

      This configures Docker daemon to listen on the standard docker socket unix:///var/run/docker.sock AND on localhost:2375.
      WARNING : I’m not enabling TLS here just for simplicity

    2. On my local machine I update the docker host environment variable to point at my swarm master node.
      $ export DOCKER_HOST="tcp://XX.XX.XX.XX:2377" (populate with your IP)

    3. Navigate to the directory of my docker-compose.yml file

    4. Create a bundle file from my docker-compose.yml file. Make sure to include the .dab extension.
      docker-compose bundle --fetch-digests -o myNewBundleFile.dab

    5. Create an application stack from the bundle file. Do not specify the .dab extension here.
      $ docker deploy myNewBundleFile

    Now I’m still experiencing some networking related issues but I have successfully gotten my service up and running from my unmodified docker-compose.yml files. The network issues I’m experiencing is documented here :

    While the official support for Swarm mode in Docker Compose is still in progress, I’ve created a simple script that takes docker-compose.yml file and runs docker service commands for you. See for details.

    It is not possible. Compose uses containers to create a client-side concept of a service. Docker 1.12 Swarm mode introduces a new server-side concept of a service.

    You are correct that docker-compose bundle; docker stack deploy is the way to get a Compose file running in Swarm Mode.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.