docker-compose up fails with “ Unable to find a node that satisfies the following conditions ”

My docker-compose.yml is:

version: '2'


    build: ./postgres
      - "5432:5432"
      - postgres-data:/data
    env_file: .env
      - "constraint:node=edge"
      - back-tier

    driver: local

    driver: overlay

And I have two nodes in a docker swarm in google. I created them with the following:

  • Accessing enviroment variables from a linked container
  • Duplicate mappings when building docker package using sbt-native-packager
  • Java version updated on package installation
  • Can not register more than one subdomain this nginx and nginx-proxy with docker container
  • Docker service failed to start application container engine on CentOS7
  • docker-machine:Error with pre-create check: “exit status 126”
  • ## Swarm master
    docker-machine --debug create --driver google --google-project my_project --swarm --swarm-discovery="consul://$cip:8500" --engine-opt="cluster-store=consul://$cip:8500" --engine-opt="cluster-advertise=eth0:2376" --swarm-master --engine-label node=director --google-disk-size 100 --google-machine-type n1-standard-2 director
    ## Nodo edge
    docker-machine --debug create --driver google --google-project my_project --swarm --swarm-discovery="consul://$cip:8500" --engine-opt="cluster-store=consul://$cip:8500" --engine-opt="cluster-advertise=eth0:2376" --engine-label node=edge --google-scopes --google-disk-size 250 --google-machine-type n1-standard-4 node-0

    And I can see both of them with docker-machine ls

    consul            -           google      Running   tcp://X.X.X.X:2376                       v1.11.0   
    director          * (swarm)   google      Running   tcp://X.X.X.X:2376   director (master)   v1.11.0   
    node-0            -           google      Running   tcp://X.X.X.X:2376    director            v1.11.0   

    And the labels worked:

    $ docker-machine ls --filter label=node=edge            
    NAME     ACTIVE   DRIVER   STATE     URL                        SWARM   DOCKER    ERRORS
    node-0   -        google   Running   tcp://X.X.X.X:2376           v1.11.0   

    The docker info output is

    $ docker info
    Containers: 3
     Running: 3
     Paused: 0
     Stopped: 0
    Images: 4
    Server Version: swarm/1.2.0
    Role: primary
    Strategy: spread
    Filters: health, port, dependency, affinity, constraint
    Nodes: 2
      └ Status: Healthy
      └ Containers: 2
      └ Reserved CPUs: 0 / 2
      └ Reserved Memory: 0 B / 7.67 GiB
      └ Labels: executiondriver=, kernelversion=4.2.0-18-generic, node=director, operatingsystem=Ubuntu 15.10, provider=google, storagedriver=aufs
      └ Error: (none)
      └ UpdatedAt: 2016-04-24T04:43:50Z
      └ ServerVersion: 1.11.0
      └ Status: Healthy
      └ Containers: 1
      └ Reserved CPUs: 0 / 4
      └ Reserved Memory: 0 B / 15.42 GiB
      └ Labels: executiondriver=, kernelversion=4.2.0-18-generic, node=edge, operatingsystem=Ubuntu 15.10, provider=google, storagedriver=aufs
      └ Error: (none)
      └ UpdatedAt: 2016-04-24T04:43:41Z
      └ ServerVersion: 1.11.0
    Kernel Version: 4.2.0-18-generic
    Operating System: linux
    Architecture: amd64
    CPUs: 6
    Total Memory: 23.09 GiB
    Name: director
    Docker Root Dir: 
    Debug mode (client): false
    Debug mode (server): false
    WARNING: No kernel memory limit support

    So everything seems right, right?

    But when I try to run docker-compose up -d

    The following happens:

    $ docker-compose up -d
    Creating network "infraestructura_back-tier" with driver "overlay"
    Creating volume "infraestructura_postgres-data" with local driver
    Building db
    Step 1 : FROM postgres:9.5
     ---> 0f3af79d8673
    Step 2 : ADD create_tables.sql /docker-entrypoint-initdb.d
     ---> Using cache
     ---> 2f818eec1228
    Successfully built 2f818eec1228
    WARNING: Image for service db was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
    Creating infraestructura_db_1
    ERROR: for db  Unable to find a node that satisfies the following conditions 
    [port 5432 (Bridge mode)]

    This is happenning not matter what I do (trying another image, destroying and recreating the nodes, etc.) , except removing the "constraint:node=edge"

    What I am doing wrong?

    BTW, my versions are:

    $ docker version
     Version:      1.11.0
     API version:  1.23
     Go version:   go1.5.4
     Git commit:   4dc5990
     Built:        Wed Apr 13 18:38:59 2016
     OS/Arch:      linux/amd64
     Version:      swarm/1.2.0
     API version:  1.22
     Go version:   go1.5.4
     Git commit:   a6c1f14
     Built:        Wed Apr 13 05:58:31 UTC 2016
     OS/Arch:      linux/amd64
    $ docker-machine -v
    docker-machine version 0.6.0, build e27fb87
    $ docker-compose -v
    docker-compose version 1.7.0, build 0d7bf73
    $ docker run --rm swarm -version
    swarm version 1.2.0 (a6c1f14)

  • Docker Container Based on Non Existing Image?
  • How to configure Docker mysql + aspnet
  • docker-compose creating multiple instances for the same image
  • docker websphere can't get the admin console
  • How can I structure my docker projects for easy deployment?
  • docker pull fails (not found) yet “number of pulls” increases
  • 3 Solutions collect form web for “docker-compose up fails with “ Unable to find a node that satisfies the following conditions ””

    You may try to change this line:

    - "constraint:node=edge"


    - "constraint:node==edge"

    The error mentions port 5432.

    ERROR: for db  Unable to find a node that satisfies the following conditions 
    [port 5432 (Bridge mode)]

    So Docker fails after checking if there is a node with port 5432 open.
    Are you sure that Postgres isn’t already running on both nodes or some other container is already listening on port 5432?

    Can you destroy the old containers with docker-compose rm before creating the new ones.

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