0

I am setting up CouchDB using docker-compose with the following docker-compose.yml (the following is a minimal example):

version: "3.6"
  services:
    couchdb:
      container_name: couchdb
      image: apache/couchdb:2.2.0
      restart: always
      ports:
      - 5984:5984
      volumes:
      - ./test/couchdb/data:/opt/couchdb/data
      environment:
      - 'COUCHDB_USER=admin'
      - 'COUCHDB_PASSWORD=password'

  couchdb_setup:
    depends_on: ['couchdb']
    container_name: couchdb_setup
    image: apache/couchdb:2.2.0
    command: ['/bin/bash', '-x', '-c', 'cat /usr/local/bin/couchdb_setup.sh | tr -d "\r" | bash']
    volumes:
    - ./scripts/couchdb_setup.sh:/usr/local/bin/couchdb_setup.sh:ro
    environment:
    - 'COUCHDB_USER=admin'
    - 'COUCHDB_PASSWORD=password'

The setup script of the second container is executing the script ./scripts/couchdb_setup.sh that starts with:

until curl -f http://couchdb:5984; do
  sleep 1
done

Now, the issue is that the curl call is always returning The requested URL returned error: 502 Bad Gateway. I figured that CouchDB is only listening on http://localhost:5984 but not on http://couchdb:5984 as is evident when I bash into the couchdb container and issue both curls; for http://localhost:5984 I get the expected response, for http://couchdb:5984 as well as http://<CONTAINER_IP>:5984 (that's http://192.168.32.2:5984, in my case) responds with server 192.168.32.2 is unreachable ...

I looked into the configs and especially into the [chttp] settings and its bind_address argument. By default, bind_address is set to any, but I have also tried using 0.0.0.0, to no avail.

I'm looking for hints what I did wrong and for advice how to set up CouchDB with docker-compose. Any help is appreciated.

  • This is probably a Docker issue, not a CouchDB issue. – Jonathan Hall Aug 29 '18 at 05:40
  • 1
    Thanks. After more debugging... @Flimzy was right. The `couchdb` network request was routed via the docker engine's proxy. This became evident by 5984 port to 0.0.0.0, which allowed me to access CouchDB from the host via localhost as well as remotely from other machines. Using a proxy server on the host (next to docker) helps with the routing. Lesson learned. – my-name-is-nobody Aug 29 '18 at 13:13

0 Answers0