Running Elastic 5.4 on CentOS-Docker(installed by binary file) does not bound

Hi. I am trying to run elasticsearch on centos-docker image.
As far as I know, since running daemon inside the docker container has some problem(like auth..),
I made a Dockerfile like below.

FROM centos
MAINTAINER juneyoung <juneyoung@hanmail.net>

ARG u=elastic
ARG uid=1000
ARG g=elastic
ARG gid=1000
ARG p=elastic

# add USER
RUN groupadd -g ${gid} ${g}
RUN useradd -d /home/${u} -u ${uid} -g ${g} -s /bin/bash ${u} 

# yum settings
RUN yum -y update
RUN yum -y install java-1.8.0-openjdk.x86_64
ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64/jre/

# install wget
RUN yum install -y wget

# install net-tools : netstat, ifconfig
RUN yum install -y net-tools

# Elasticsearch install
ENV ELASTIC_VERSION=5.4.0

# Binary install
RUN wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ELASTIC_VERSION}.tar.gz
RUN tar -xvf elasticsearch-${ELASTIC_VERSION}.tar.gz
RUN mv elasticsearch-${ELASTIC_VERSION} /home/${u}
RUN rm elasticsearch-${ELASTIC_VERSION}.tar.gz
ENV ELASTIC_HOME=/home/${u}/elasticsearch-${ELASTIC_VERSION}/

# PATH reset
ENV PATH=${PATH}:${ELASTIC_HOME}/bin

RUN chown -R ${u}:${g} /home/${u}
USER ${u}

EXPOSE 9200 9300

CMD ["elasticsearch"]

I have no trouble with building an image and running the container.
However I can not access elasticsearch via url.

I am using OSX 10, and same setting works in host.
Is there anything I have to do ?

Thanks!

FYI, docker logs looks below

[2017-06-05T01:09:02,721][INFO ][o.e.n.Node               ] [] initializing ...
[2017-06-05T01:09:03,744][INFO ][o.e.e.NodeEnvironment    ] [_j5tAyk] using [1] data paths, mounts [[/ (overlay)]], net usable_space [57.5gb], net total_space [62.7gb], spins? [possibly], types [overlay]
[2017-06-05T01:09:03,745][INFO ][o.e.e.NodeEnvironment    ] [_j5tAyk] heap size [1.9gb], compressed ordinary object pointers [true]
[2017-06-05T01:09:03,750][INFO ][o.e.n.Node               ] node name [_j5tAyk] derived from node ID [_j5tAykbSgacBJ_DWDVrOQ]; set [node.name] to override
[2017-06-05T01:09:03,751][INFO ][o.e.n.Node               ] version[5.4.0], pid[1], build[780f8c4/2017-04-28T17:43:27.229Z], OS[Linux/4.9.27-moby/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_131/25.131-b12]
[2017-06-05T01:09:07,259][INFO ][o.e.p.PluginsService     ] [_j5tAyk] loaded module [aggs-matrix-stats]
[2017-06-05T01:09:07,260][INFO ][o.e.p.PluginsService     ] [_j5tAyk] loaded module [ingest-common]
[2017-06-05T01:09:07,261][INFO ][o.e.p.PluginsService     ] [_j5tAyk] loaded module [lang-expression]
[2017-06-05T01:09:07,261][INFO ][o.e.p.PluginsService     ] [_j5tAyk] loaded module [lang-groovy]
[2017-06-05T01:09:07,261][INFO ][o.e.p.PluginsService     ] [_j5tAyk] loaded module [lang-mustache]
[2017-06-05T01:09:07,261][INFO ][o.e.p.PluginsService     ] [_j5tAyk] loaded module [lang-painless]
[2017-06-05T01:09:07,262][INFO ][o.e.p.PluginsService     ] [_j5tAyk] loaded module [percolator]
[2017-06-05T01:09:07,263][INFO ][o.e.p.PluginsService     ] [_j5tAyk] loaded module [reindex]
[2017-06-05T01:09:07,264][INFO ][o.e.p.PluginsService     ] [_j5tAyk] loaded module [transport-netty3]
[2017-06-05T01:09:07,264][INFO ][o.e.p.PluginsService     ] [_j5tAyk] loaded module [transport-netty4]
[2017-06-05T01:09:07,266][INFO ][o.e.p.PluginsService     ] [_j5tAyk] no plugins loaded
[2017-06-05T01:09:13,563][INFO ][o.e.d.DiscoveryModule    ] [_j5tAyk] using discovery type [zen]
[2017-06-05T01:09:14,889][INFO ][o.e.n.Node               ] initialized
[2017-06-05T01:09:14,902][INFO ][o.e.n.Node               ] [_j5tAyk] starting ...
[2017-06-05T01:09:15,359][INFO ][o.e.t.TransportService   ] [_j5tAyk] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2017-06-05T01:09:18,915][INFO ][o.e.c.s.ClusterService   ] [_j5tAyk] new_master {_j5tAyk}{_j5tAykbSgacBJ_DWDVrOQ}{ycVg876bRpqKGYyZGh8L_Q}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
[2017-06-05T01:09:19,011][INFO ][o.e.h.n.Netty4HttpServerTransport] [_j5tAyk] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2017-06-05T01:09:19,019][INFO ][o.e.n.Node               ] [_j5tAyk] started
[2017-06-05T01:09:19,065][INFO ][o.e.g.GatewayService     ] [_j5tAyk] recovered [0] indices into cluster_state
[2017-06-05T01:09:49,559][INFO ][o.e.m.j.JvmGcMonitorService] [_j5tAyk] [gc][34] overhead, spent [592ms] collecting in the last [1.5s]

what is the error you are getting when accessing the address?
just regular 404?

you also have an image of elastic in docker hub, that way you just run that image and not building an image alone from docker file.
I use docker-compose to run my container and its going smoothly. you should try that out.

No. It is just ERR_EMPTY_RESPONSE.
Both ports of 9200 and 9300 in host is LISTEN status.

However, when I called it, it returns any data.
I changed approach.

I run docker with init command and attached into the container.
and inside of the container I commanded elasticsearch, but it still not accessible with browser.

maybe I should not set network.host as localhost?

try to set the network.host to 0.0.0.0

it makes it accessible from all networks

0.0.0.0 is a non-routable meta-address used to designate an invalid, unknown, or non-applicable target (a ‘no particular address’ place holder).
In the context of a route entry, it usually means the default route.

In the context of servers, 0.0.0.0 means all IPv4 addresses on the local machine. If a host has two IP addresses, 192.168.1.1 and 10.1.2.1, and a server running on the host listens on 0.0.0.0, it will be reachable at both of those IPs.

That works for me! Thank you so much!:grinning:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.