I've been trying to synchronize my mongodb with elastic for two days and I'm going crazy. After many attempts and changes in my dockerfile and in my docker-compose I get this error, but the container with mongodb is up and running.
monstache | ERROR 2018/07/27 17:59:07 Unable to connect to mongodb using URL 'mongodb:27018': no reachable servers
monstache | panic: Unable to connect to mongodb using URL 'mongodb:27018': no reachable servers
monstache |
monstache | goroutine 1 [running]:
monstache | log.(*Logger).Panicf(0xc420020c30, 0xd4fc15, 0x2d, 0xc42006fc18, 0x2, 0x2)
monstache | /usr/local/go/src/log/log.go:219 +0xdb
monstache | main.main()
monstache | /home/vagrant/go/src/github.com/rwynn/monstache/monstache.go:2400 +0x320
monstache exited with code 2
This is my dockerfile
FROM golang
ADD build-4.4.0/linux-amd64/monstache /go/bin/monstache
ENTRYPOINT ["monstache", "-mongo-url='mongodb:27018'", "-elasticsearch-url=elasticsearch:9200"]
And this is my docker-compose file
version: '3.3'
services:
mongodb:
image: mongo
restart: always
container_name: mongodb
volumes:
- ./data/mongodb:/usr/share/mongodb/data
ports:
- 27018:27017
elasticsearch:
image: elasticsearch
restart: always
container_name: elasticsearch
volumes:
- ./data/elastic:/usr/share/elasticsearch/data
ports:
- 9200:9200
monstache:
build: ./monstache/
restart: always
container_name: monstache
links:
- elasticsearch
- mongodb
Any idea?
Thanks!
Finally, we desist to use monstache, and we use mongo-connector in a python dockerfile to share the data from mongodb to elasticsearch.
FROM python:3.4.3
RUN pip install 'mongo-connector[elastic5]' && \
pip install 'elastic2-doc-manager[elastic5]'
I hope this can help to someone.