Reputation: 1117
I am trying to implement elastic search in my rails web app. I am using docker. I used this link for reference. My docker-compose.yml file is:
mysql:
image: mysql:5.6.34
ports:
- "3002:3002"
volumes_from:
- dbdata
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=dev
dbdata:
image: tianon/true
volumes:
- /var/lib/mysql
web:
build: .
environment:
RAILS_ENV: development
ports:
- '3000:3000'
volumes_from:
- appdata
links:
- "mysql"
- elasticsearch
appdata:
image: tianon/true
volumes:
- ".:/workspace"
elasticsearch:
image: elasticsearch
ports:
- "9200:9200"
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
mem_limit: 1g
cap_add:
- IPC_LOCK
volumes:
- /usr/share/elasticsearch/data
When I am trying to run Student.__elasticsearch__.create_index! force:true
as indicated in the above given link. I am getting following error:
Upvotes: 3
Views: 1558
Reputation: 13804
You need to set ENV for ELASTICSEARCH_URL
to correct value
ELASTICSEARCH_URL="http://<ip-of-your-docker-container>:9200"
As you have linked network, you can provide as bellow
ELASTICSEARCH_URL="http://elasticsearch:9200"
Links allow you to define extra aliases by which a service is reachable from another service. Any service can reach any other service at that service’s name
If no ENV is set, your rails app will use http://localhost:9200
Upvotes: 4