1

I have the following docker containers running on my windows 10 host:

PS C:\Users\jj2> docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                                                  NAMES
aacbb0c8f189        couchdb:2.1.1       "tini -- /docker-ent…"   15 seconds ago      Up 12 seconds       4369/tcp, 9100/tcp, 0.0.0.0:15984->5984/tcp, 0.0.0.0:15986->5986/tcp   jj2_server-1_1
b00138d9c030        couchdb:2.1.1       "tini -- /docker-ent…"   16 seconds ago      Up 12 seconds       4369/tcp, 9100/tcp, 0.0.0.0:25984->5984/tcp, 0.0.0.0:25986->5986/tcp   jj2_server-2_1
e4c984413ac1        couchdb:2.1.1       "tini -- /docker-ent…"   16 seconds ago      Up 12 seconds       0.0.0.0:5984->5984/tcp, 4369/tcp, 9100/tcp, 0.0.0.0:5986->5986/tcp     jj2_server-0_1

And I'm able to launch Fauxton like so for each instance:

http://127.0.0.1:5984/
http://127.0.0.1:15984/
http://127.0.0.1:25984/

Now I try to set up replication on the main container … but I must be messing up the value for replication target. these are the values I'm specifying:

Replication Source:    Local Database
Source Name:   widgets
Replication Target:    New Remote Database
New Database: http://127.0.0.1:15984/widgets
Replication Type:  Continuous

When I save this, the replication attempt fails... and if I reopen the configuration tool, the target is changed to "Existing local database".

This is what the original config JSON looks like:

{
  "_id": "310ab1c7a68d4ae4aba039d2fa00320f",
  "_rev": "2-cf1a3abced5f09ceebd9d54f42ebd65d",
  "user_ctx": {
    "name": "couchdb",
    "roles": [
      "_admin",
      "_reader",
      "_writer"
    ]
  },
  "source": {
    "headers": {
      "Authorization": "Basic Y291Y2hkYjpwYXNzd29yZA=="
    },
    "url": "http://127.0.0.1:5984/widgets"
  },
  "target": {
    "headers": {
      "Authorization": "Basic Y291Y2hkYjpwYXNzd29yZA=="
    },
    "url": "http://127.0.0.1:15984/widgets"
  },
  "create_target": true,
  "continuous": true,
  "owner": "couchdb"
}

the hint / help for the "New Database" field seems to indicate I need to use a URL... which is why I tried the 127.0.0.1.

Any suggestions would be appreciated.

EDIT 1

ONe thing I should add is that the 2 additional nodes have not had a setup run on them. Meaning, I created the cluster, but when I launch the webapp, it prompts me to create either a single node or a cluster. do I have to set up each node as a single node before replication will work?

Also, this is how I created the cluster / containers in the first place: https://github.com/apache/couchdb-docker/issues/74 I used that docker-compose.yml file.

EDIT 2

I know realize / learned that anything 127.0.0.1 will be pointing to the HOST machine which is where I've strayed. But how do I point one container to another?
As far as the cluster goes, using fauxton running on 127.0.0.1:5984, for server-0 i have added the following 2 nodes like so :

couchdb-1:5984 bind address 0.0.0.0 couchdb-2:5984 bind address 0.0.0.0

Then when I do this (notice the port):

 http://127.0.0.1:15984/_node/couchdb@couchdb-1/_config

I get a legit json response showing that something is running under the name "couchdb-1". However, I realize that I'm still using my HOST machine to get a view into couchdb-1 server. (server-1)

Via commandline, I confirmed I have nodes like so:

PS C:\Users\jj2> curl -X GET "http://127.0.0.1:5984/_membership" --user couchdb Enter host password for user 'couchdb': {"all_nodes":["couchdb@couchdb-0"],"cluster_nodes":["couchdb@couchdb-0","couchdb@couchdb-1","couchdb@couchdb-2"]} PS C:\Users\jj2>

Lastly, I thought maybe the I could use the IP addresss of the containers assigned by docker, but none of them are pingable from the host. They are all 172.x.x.x addresses.

EDIT 3

IN case it helps.

PS C:\Users\jj2> docker network inspect jj2_network
[
    {
        "Name": "jj2_network",
        "Id": "a0a799f7069ff49306438d9cb7884399a66470a7f0e9ac5364600c462153f53c",
        "Created": "2020-01-30T21:18:55.5841557Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.19.0.0/16",
                    "Gateway": "172.19.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": true,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "006b6d02cd4e962f3df9d6584d58b36b67864872446f2d00209001ec58d3cd52": {
                "Name": "jj2_server-1_1",
                "EndpointID": "91260368a2d5014743b41c9ab863a2acbfe0a8c7f0a18ea7ad35a3c16efb4445",
                "MacAddress": "02:42:ac:13:00:03",
                "IPv4Address": "172.19.0.3/16",
                "IPv6Address": ""
            },
            "15b261831c46fb89cdc83f9deb638ada0d9d8a89ece0bc065e0a45818e9b4ce3": {
                "Name": "jj2_server-2_1",
                "EndpointID": "cf072d0bbd95ab86308ac4c15b71b47223b09484506e07e5233d526f46baca1e",
                "MacAddress": "02:42:ac:13:00:04",
                "IPv4Address": "172.19.0.4/16",
                "IPv6Address": ""
            },
            "aeaf74cf591cffa8e7463e82b75e9ca57ebbcfd1a84d3f893ea5dcae324dbd1e": {
                "Name": "jj2_server-0_1",
                "EndpointID": "0a6d66b95bf973f0432b9ae88c61709e63f9e51c6bbf92e35ddf6eab5f694cc1",
                "MacAddress": "02:42:ac:13:00:02",
                "IPv4Address": "172.19.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {
            "com.docker.compose.network": "network",
            "com.docker.compose.project": "jj2",
            "com.docker.compose.version": "1.24.1"
        }
    }
]
dot
  • 14,928
  • 41
  • 110
  • 218
  • You must use a URL that each CouchDB instance can resolve. When you use `http://127.0.0.1:15984`, the CouchDB instance tries to connect to that IP--which is itself. – Jonathan Hall Jan 29 '20 at 20:45
  • But it's a different port … so I guess it's not looking at the port? Browser works fine and launches the web application for the separate containers. – dot Jan 29 '20 at 20:45
  • There is nothing running on that port, locally. It works from the browser, because from your machine, those ports are accessible. But within the Docker containers, they are not. – Jonathan Hall Jan 29 '20 at 20:46
  • "127.0.0.1" means something different on your host, and within each docker container. – Jonathan Hall Jan 29 '20 at 20:47
  • @Flimzy ok thanks. I've updated my post with a clarified / more specific question. – dot Jan 31 '20 at 18:38

1 Answers1

0

Do you have the docker instances bound to 0.0.0.0 or just 127.0.0.1

If 0.0.0.0 then you can replicate by setting source and target as remote database with the IP address of the local machine and the specific ports for each instance.

If only 127.0.0.1 and they are both on the same docker network (see docker network ls and docker network inspect <network_name>) then you can use the docker network IP addresses to replicate between the containers.

naven87
  • 964
  • 1
  • 7
  • 24