Use docker-compose with docker swarm

I’m using docker 1.12.1
I have an easy docker-compose script.

version: '2'

    build: ./slave
    image: jenkins-slave:1.0
    restart: always
     - "22"
     - "constraint:NODE==master1"
    image: jenkins:2.7.1
    container_name: jenkins-master
    restart: always
     - "8080:8080"
     - "50000"
     - "constraint:NODE==node1"

I run this script with docker-compose -p jenkins up -d.
This Creates my 2 containers but only on my master (from where I execute my command). I would expect that one would be created on the master and one on the node.
I also tried to add

  • I can't locate my host directory, which I attached to Docker
  • Uploading and storing Docker certificates for connecting to remote Docker machines
  • Running the index structure creator command in an Elasticsearch Docker
  • Docker Compose raise an AccessDeniedExpcetion
  • Spring Boot Integration feed sleeps due inactivity
  • Consul docker - advertise flag ignored
  • networks:
        driver: overlay


         - jenkins_swarm

    After every service but this is failing with:

    Cannot create container for service jenkins-master: network jenkins_jenkins_swarm not found

    While the network is created when I perform docker network ls

    Someone who can help me to deploy 2 containers on my 2 nodes with docker-compose. Swarm is defenitly working on my “cluster”. I followed this tutorial to verify.

  • view a stream PipelineDB like a log
  • Docker Wordpress High CPU Usage
  • How to run Percona XtraDB Cluster with external data directory?
  • docker-compose NodeJS + Mongodb with mongoose, dynamically get the mongo container ip
  • cannot ADD file in current directory or in the directory with full path
  • Debian : Using a cron task on Docker
  • One Solution collect form web for “Use docker-compose with docker swarm”

    Compose doesn’t support Swarm Mode at the moment.

    When you run docker compose up on the master node, Compose issues docker run commands for the services in the Compose file, rather than docker service create – which is why the containers all run on the master. See this answer for options.

    On the second point, networks are scoped in 1.12. If you inspect your network you’ll find it’s been created at swarm-level, but Compose is running engine-level containers which can’t see the swarm network.

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