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

My docker-compose.yml is:

version: '2'

services:

  db:
    build: ./postgres
    ports:
      - "5432:5432"
    volumes:
      - postgres-data:/data
    env_file: .env
    environment:
      - "constraint:node=edge"
    networks:
      - back-tier

volumes:
  postgres-data:
    driver: local

networks:
  back-tier:
    driver: overlay

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

  • How to move docker containers between different hosts
  • docker-compose got error when bringing up nodejs application docker container
  • Gitlab CI: Persist MySQL data between stages
  • How to run appium test using aluedeke/appium-android docker image?
  • Download all dependencies, plugin dependencies, compilers, etc. with Maven?
  • sudo docker run: unbound variable error
  • ## 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 https://www.googleapis.com/auth/devstorage.read_write --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
     director: 104.154.88.186:2376
      └ 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
     node-0: 104.197.85.59:2376
      └ 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
    Plugins: 
     Volume: 
     Network: 
    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
    Client:
     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
    
    Server:
     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 - creating and starting container, differences between API and CLI
  • Configure PM2 module with linked docker container
  • Can't get docker to accept request over the internet
  • google container engine having problems pulling image from container registry
  • Installing Pillow requirements on debian Jessie
  • NodeJS: How to do nightmareJS e2e-testing on running docker application
  • 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"
    

    to

    - "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.