run26kimo / searchkick_example

gem searchkick Demo
3 stars 1 forks source link

Can this project run on Docker? #1

Open e212156822000 opened 6 years ago

e212156822000 commented 6 years ago

大大您好,我在您的網誌看到了您用Docker部署elasticsearch + searchkick + rails,想問您是否保留先前的docker-compose.yml file,想要參考看看,我目前裝起來一直噴Failed to open TCP connection to localhost:9200這個錯,也照網誌的說法用network把web(rails)、db(pg)、elasticsearch連起來了,但無濟於事。

目前curl 172.0.0.1:9200都是正常的。 以下是我的docker-compose內容:

version: '3'
services:
  db:
    image: postgres
    volumes:
      - .:/ruby_practice/db
  web:
    build: .
    command: rails server -p 5000 -b 0.0.0.0
    volumes:
      - .:/ruby_practice
    ports:
      - "5000:5000"
    links:
      - db
      - elasticsearch
    depends_on:
      - db
      - elasticsearch
    networks:
      - app-tier
  elasticsearch:
    image: elasticsearch
    environment:
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - "discovery.zen.ping.unicast.hosts=elasticsearch"
      - network.host=0.0.0.0
      - network.bind_host="0"
      - network.bind_host="::"
      - discovery.type=single-node
      - cluster.name=elasticsearch
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:  
      - /usr/share/elasticsearch/data
    ports:
      - 9200:9200
      - 9300:9300
    networks:
      - app-tier
  kibana:
    image: kibana
    links:
      - elasticsearch
    ports:
      - 5601:5601
    networks:
      - app-tier
networks:
  app-tier:

非常謝謝你看完!

e212156822000 commented 6 years ago

I got a solution for docker + rails + elasticsearch + searchkick. Here is my content of docker-compose.yml:

version: '3'
services:
  db:
    image: postgres
    volumes:
      - .:/ruby_practice/db
  web:
    build: .
    command: rails server -p 5000 -b '0.0.0.0'
    ports:
      - "5000:5000"
    volumes:
      - .:/ruby_practice
    links:
      - db
      - elasticsearch
    environment:
      - ELASTICSEARCH_URL=http://elasticsearch:9200
  elasticsearch:
    image: elasticsearch
    ports:
      - "9200:9200"
    environment:
      - bootstrap.memory_lock=true
      - xpack.security.enabled=false
      - network.host=0.0.0.0
      - cluster.name=elasticsearch
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - "http.host=0.0.0.0"
      - "transport.host=127.0.0.1"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:  
      - /usr/share/elasticsearch/data