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://123.123.123.123:3375"
and then simply execute commands as if you were running them against a single instance of Docker engine.

  • Using docker-compose Mysql + App
  • Docker image running as unknown user ID can delete root files
  • What does the DOCKER_TLS_VERIFY and DOCKER_CERT_PATH variable do?
  • How to get the hostname of the docker host from inside a docker container on that host without env vars
  • How to access an docker's image file system
  • what does fd:// mean exactly in dockerd -H fd://
  • OR is this functionality something that docker-compose bundle is replacing?

  • Recommend way to Artisan on Docker
  • mysqli not found in (php-fpm) docker container
  • LaTeX in docker container using Alpine Linux (repository for Latex)
  • How to change docker daemon root directory in CentOS7
  • Openstack Nova docker implement security group
  • PHP application moving to Docker failed to connect on AWS
  • 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 https://github.com/docker/docker/blob/master/experimental/docker-stacks-and-bundles.md
    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://0.0.0.0:2375 &

      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 : https://github.com/docker/docker/issues/23901

    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 https://github.com/ddrozdov/docker-compose-swarm-mode 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.