Search code examples
elasticsearchdockerdocker-composedocker-machineelastic-stack

Docker-compose.yml Is not working for elasticserch


Version Used:

Docker-compose = 1.3.2
Docker = 1.12.3
Os: Ubuntu-14.04LTS

1: Compose file contents:

docker-compose.yml

elk: 
  image: elasticsearch:latest       
  ports:  
    - "9200:9200"
    - "9300:9300"
  volumes:
    - ./Elasticsearch/data:/etc/elasticsearch/data
    - ./Elasticsearch/config/elasticsearch.yml:/etc/elasticsearch/config/elasticsearch.yml
  command: bash -c "service elasticsearch start"
  tty : true

2: $ Running compose file:

docker-compose up

Getting Following:

Attaching to elkdockerdir_elk_1
elk_1 | [2016-11-14T06:28:18,458][INFO ][o.e.n.Node               ] [] initializing ...
elk_1 | [2016-11-14T06:28:18,573][INFO ][o.e.e.NodeEnvironment    ] [UERHECj] using [1] data paths, mounts [[/usr/share/elasticsearch/data (/dev/sda6)]], net usable_space [409.6gb], net total_space [442.8gb], spins? [possibly], types [ext4]
elk_1 | [2016-11-14T06:28:18,573][INFO ][o.e.e.NodeEnvironment    ] [UERHECj] heap size [1.9gb], compressed ordinary object pointers [true]
elk_1 | [2016-11-14T06:28:18,576][INFO ][o.e.n.Node               ] [UERHECj] node name [UERHECj] derived from node ID; set [node.name] to override
elk_1 | [2016-11-14T06:28:18,579][INFO ][o.e.n.Node               ] [UERHECj] version[5.0.0], pid[1], build[253032b/2016-10-26T05:11:34.737Z], OS[Linux/3.13.0-32-generic/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_111/25.111-b14]
elk_1 | [2016-11-14T06:28:19,066][INFO ][o.e.p.PluginsService     ] [UERHECj] loaded module [aggs-matrix-stats]
elk_1 | [2016-11-14T06:28:19,066][INFO ][o.e.p.PluginsService     ] [UERHECj] loaded module [ingest-common]
elk_1 | [2016-11-14T06:28:19,066][INFO ][o.e.p.PluginsService     ] [UERHECj] loaded module [lang-expression]
elk_1 | [2016-11-14T06:28:19,066][INFO ][o.e.p.PluginsService     ] [UERHECj] loaded module [lang-groovy]
elk_1 | [2016-11-14T06:28:19,066][INFO ][o.e.p.PluginsService     ] [UERHECj] loaded module [lang-mustache]
elk_1 | [2016-11-14T06:28:19,066][INFO ][o.e.p.PluginsService     ] [UERHECj] loaded module [lang-painless]
elk_1 | [2016-11-14T06:28:19,066][INFO ][o.e.p.PluginsService     ] [UERHECj] loaded module [percolator]
elk_1 | [2016-11-14T06:28:19,067][INFO ][o.e.p.PluginsService     ] [UERHECj] loaded module [reindex]
elk_1 | [2016-11-14T06:28:19,067][INFO ][o.e.p.PluginsService     ] [UERHECj] loaded module [transport-netty3]
elk_1 | [2016-11-14T06:28:19,067][INFO ][o.e.p.PluginsService     ] [UERHECj] loaded module [transport-netty4]
elk_1 | [2016-11-14T06:28:19,067][INFO ][o.e.p.PluginsService     ] [UERHECj] no plugins loaded
elk_1 | [2016-11-14T06:28:19,149][WARN ][o.e.d.s.g.GroovyScriptEngineService] [groovy] scripts are deprecated, use [painless] scripts instead
elk_1 | [2016-11-14T06:28:20,424][INFO ][o.e.n.Node               ] [UERHECj] initialized
elk_1 | [2016-11-14T06:28:20,424][INFO ][o.e.n.Node               ] [UERHECj] starting ...
elk_1 | [2016-11-14T06:28:20,571][INFO ][o.e.t.TransportService   ] [UERHECj] publish_address {172.17.0.2:9300}, bound_addresses {[::]:9300}
elk_1 | [2016-11-14T06:28:20,576][INFO ][o.e.b.BootstrapCheck     ] [UERHECj] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
elk_1 | ERROR: bootstrap checks failed
elk_1 | max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
elk_1 | [2016-11-14T06:28:20,587][INFO ][o.e.n.Node               ] [UERHECj] stopping ...
elk_1 | [2016-11-14T06:28:20,608][INFO ][o.e.n.Node               ] [UERHECj] stopped
elk_1 | [2016-11-14T06:28:20,608][INFO ][o.e.n.Node               ] [UERHECj] closing ...
elk_1 | [2016-11-14T06:28:20,620][INFO ][o.e.n.Node               ] [UERHECj] closed
elkdockerdir_elk_1 exited with code 78
Gracefully stopping... (press Ctrl+C again to force)

3: $ Check the container:

docker ps -a
    CONTAINER ID        IMAGE                  COMMAND                  CREATED              STATUS                           PORTS               NAMES
    a8799b8fe969        elasticsearch:latest   "/docker-entrypoint.s"   About a minute ago   Exited (78) About a minute ago                       elkdockerdir_elk_1

Partial solution:

service elasticsearch is not keep running, so the after adding bash -c "service elasticsearch start && tail -f /dev/null its working fine , Please check after $ docker ps -a

CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS                       PORTS                              NAMES
bfbc12a69a8a        elasticsearch:latest   "/docker-entrypoint.s"   13 seconds ago      Up 12 seconds                0.0.0.0:9200->9200/tcp, 9300/tcp   elkdockerdir_elk_1

running but when testing elasticsearch by using curl: $ curl 'http://localhost:9200/?pretty' its giving error like: curl: (56) Recv failure: Connection reset by peer Also http://localhost:9200 is not working...

Not getting the exact issue...

Questions:

1: How to run docker-compose.yml with commands i.e. command: bash -c "service elasticsearch start" for given docker-compose and docker version ?


Solution

  • Looks it is trivial error in the docker-compose.yml in the command statement.

    Change from:

    command: bash -c "service elasticsearch start"
    

    To:

    command: service elasticsearch start
    

    or

    command: [service, elasticsearch, start]
    

    UPDATE: based on the comments.

    Looks like command statement isn't needed in this case.
    Removed command statement altogether from docker-compose.yml and re run docker-compose up command.

    docker-compose.yml:

    elk: 
      image: elasticsearch:latest       
      ports:  
        - "9200:9200"
        - "9300:9300"
      tty : true
    
    docker-compose up
    Creating cmp1_elk_1
    Attaching to cmp1_elk_1
    elk_1  | -14T09:28:12,095][INFO ][o.e.n.Node               ] [] initializing ...
    elk_1  | -14T09:28:14,167][INFO ][o.e.e.NodeEnvironment    ] [9KYASyV] using [1] data paths, mounts [[/usr/share/elasticsearch/data (/dev/sda2)]], net usable_space [44.1gb], net total_space [55.1gb], spins? [possibly], types [ext4]
    elk_1  | [2016-11-14T09:28:14,168][INFO ][o.e.e.NodeEnvironment    ] [9KYASyV] heap size [1.9gb], compressed ordinary object pointers [true]
    elk_1  | [2016-11-14T09:28:14,174][INFO ][o.e.n.Node               ] [9KYASyV] node name [9KYASyV] derived from node ID; set [node.name] to override
    elk_1  | [2016-11-14T09:28:14,286][INFO ][o.e.n.Node               ] [9KYASyV] version[5.0.0], pid[1], build[253032b/2016-10-26T05:11:34.737Z], OS[Linux/4.4.27-moby/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_111/25.111-b14]
    elk_1  | -14T09:28:22,109][INFO ][o.e.p.PluginsService     ] [9KYASyV] loaded module [aggs-matrix-stats]
    elk_1  | [2016-11-14T09:28:22,109][INFO ][o.e.p.PluginsService     ] [9KYASyV] loaded module [ingest-common]
    elk_1  | [2016-11-14T09:28:22,109][INFO ][o.e.p.PluginsService     ] [9KYASyV] loaded module [lang-expression]
    elk_1  | [2016-11-14T09:28:22,109][INFO ][o.e.p.PluginsService     ] [9KYASyV] loaded module [lang-groovy]
    elk_1  | [2016-11-14T09:28:22,109][INFO ][o.e.p.PluginsService     ] [9KYASyV] loaded module [lang-mustache]
    elk_1  | [2016-11-14T09:28:22,109][INFO ][o.e.p.PluginsService     ] [9KYASyV] loaded module [lang-painless]
    elk_1  | -14T09:28:22,110][INFO ][o.e.p.PluginsService     ] [9KYASyV] loaded module [percolator]
    elk_1  | [2016-11-14T09:28:22,110][INFO ][o.e.p.PluginsService     ] [9KYASyV] loaded module [reindex]
    elk_1  | [2016-11-14T09:28:22,110][INFO ][o.e.p.PluginsService     ] [9KYASyV] loaded module [transport-netty3]
    elk_1  | [2016-11-14T09:28:22,110][INFO ][o.e.p.PluginsService     ] [9KYASyV] loaded module [transport-netty4]
    elk_1  | [2016-11-14T09:28:22,110][INFO ][o.e.p.PluginsService     ] [9KYASyV] no plugins loaded
    elk_1  | -14T09:28:22,966][WARN ][o.e.d.s.g.GroovyScriptEngineService] [groovy] scripts are deprecated, use [painless] scripts instead
    elk_1  | -14T09:28:28,813][INFO ][o.e.n.Node               ] [9KYASyV] initialized
    elk_1  | [2016-11-14T09:28:28,813][INFO ][o.e.n.Node               ] [9KYASyV] starting ...
    elk_1  | -14T09:28:29,432][INFO ][o.e.t.TransportService   ] [9KYASyV] publish_address {172.17.0.2:9300}, bound_addresses {[::]:9300}
    elk_1  | -14T09:28:29,438][INFO ][o.e.b.BootstrapCheck     ] [9KYASyV] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
    elk_1  | -14T09:28:34,694][WARN ][o.e.m.j.JvmGcMonitorService] [9KYASyV] [gc][young][3][4] duration [3.1s], collections [1]/[3.8s], total [3.1s]/[4.4s], memory [163.3mb]->[81.6mb]/[1.9gb], all_pools {[young] [132.2mb]->[3.1mb]/[133.1mb]}{[survivor] [16.6mb]->[10.9mb]/[16.6mb]}{[old] [14.5mb]->[67.5mb]/[1.8gb]}
    elk_1  | [2016-11-14T09:28:34,696][WARN ][o.e.m.j.JvmGcMonitorService] [9KYASyV] [gc][3] overhead, spent [3.1s] collecting in the last [3.8s]
    elk_1  | -14T09:28:34,780][INFO ][o.e.c.s.ClusterService   ] [9KYASyV] new_master {9KYASyV}{9KYASyViTaOsIAx7vjSZZQ}{NvfMmitMSNCXVkpHo7GzmQ}{172.17.0.2}{172.17.0.2:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
    elk_1  | -14T09:28:34,895][INFO ][o.e.h.HttpServer         ] [9KYASyV] publish_address {172.17.0.2:9200}, bound_addresses {[::]:9200}
    elk_1  | [2016-11-14T09:28:34,895][INFO ][o.e.n.Node               ] [9KYASyV] started
    elk_1  | -14T09:28:35,085][INFO ][o.e.g.GatewayService     ] [9KYASyV] recovered [0] indices into cluster_state
    

    Now it is up and able to query too.

    Also, curl 'http://localhost:9200/?pretty' results below and hence it is working:

    $ curl 'http://localhost:9200/?pretty'
    {
      "name" : "9KYASyV",
      "cluster_name" : "elasticsearch",
      "cluster_uuid" : "UTZ18I0QRWmg0LFKUDE3ew",
      "version" : {
        "number" : "5.0.0",
        "build_hash" : "253032b",
        "build_date" : "2016-10-26T05:11:34.737Z",
        "build_snapshot" : false,
        "lucene_version" : "6.2.0"
      },
      "tagline" : "You Know, for Search"
    }
    

    Also from your log, it is noticed that vm.max_map_count is low. You may check here for more details.