Abhi
Abhi

Reputation: 6568

Unable to cUrl docker container

I am following the tutorial https://docker-curriculum.com/ and running the ElasticSearch image on Windows 10. But the curl is not responding to the default url that is mentioned while running the docker image. Any help is appreciated.

I ran the following commands.

$ docker pull docker.elastic.co/elasticsearch/elasticsearch:6.3.2

$ docker run -d --name es -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.3.2
e8be84174fec0bcb796265d93e67ec70b6ac77a54a4ff65be7a51f9a64037f43

Listed the containers

docker container ls
CONTAINER ID   IMAGE                                                 COMMAND                  CREATED        STATUS        PORTS                                            NAMES
572b79717617   docker.elastic.co/elasticsearch/elasticsearch:6.3.2   "/usr/local/bin/dock…"   12 hours ago   Up 12 hours   0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp   es
9ff0b5b40306   acerab/foodtrucks-web                                 "bash"                   14 hours ago   Up 14 hours   5000/tcp

Listed the Elastic Search Container container es logs

$ docker container logs es

OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
[2023-01-19T03:57:00,940][INFO ][o.e.n.Node               ] [] initializing ...
[2023-01-19T03:57:01,007][INFO ][o.e.e.NodeEnvironment    ] [-dsoNEx] using [1] data paths, mounts [[/ (overlay)]], net usable_space [233.8gb], net total_space [250.9gb], types [overlay]
[2023-01-19T03:57:01,007][INFO ][o.e.e.NodeEnvironment    ] [-dsoNEx] heap size [989.8mb], compressed ordinary object pointers [true]
[2023-01-19T03:57:01,010][INFO ][o.e.n.Node               ] [-dsoNEx] node name derived from node ID [-dsoNExNSMmYeeQDYc3-Og]; set [node.name] to override
[2023-01-19T03:57:01,010][INFO ][o.e.n.Node               ] [-dsoNEx] version[6.3.2], pid[1], build[default/tar/053779d/2018-07-20T05:20:23.451332Z], OS[Linux/5.10.102.1-microsoft-standard-WSL2/amd64], JVM["Oracle Corporation"/OpenJDK 64-Bit Server VM/10.0.2/10.0.2+13]
[2023-01-19T03:57:01,010][INFO ][o.e.n.Node               ] [-dsoNEx] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.io.tmpdir=/tmp/elasticsearch.mV5lGAl6, -XX:+HeapDumpOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_err_pid%p.log, -Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m, -Djava.locale.providers=COMPAT, -XX:UseAVX=2, -Des.cgroups.hierarchy.override=/, -Des.path.home=/usr/share/elasticsearch, -Des.path.conf=/usr/share/elasticsearch/config, -Des.distribution.flavor=default, -Des.distribution.type=tar]
[2023-01-19T03:57:03,139][INFO ][o.e.p.PluginsService     ] [-dsoNEx] loaded plugin [ingest-user-agent]
[2023-01-19T03:57:06,403][INFO ][o.e.x.s.a.s.FileRolesStore] [-dsoNEx] parsed [0] roles from file [/usr/share/elasticsearch/config/roles.yml]
[2023-01-19T03:57:06,987][INFO ][o.e.x.m.j.p.l.CppLogMessageHandler] [controller/118] [Main.cc@109] controller (64 bit): Version 6.3.2 (Build 903094f295d249) Copyright (c) 2018 Elasticsearch BV
[2023-01-19T03:57:07,660][INFO ][o.e.d.DiscoveryModule    ] [-dsoNEx] using discovery type [single-node]
[2023-01-19T03:57:08,732][INFO ][o.e.n.Node               ] [-dsoNEx] initialized
[2023-01-19T03:57:08,732][INFO ][o.e.n.Node               ] [-dsoNEx] starting ...
[2023-01-19T03:57:08,944][INFO ][o.e.t.TransportService   ] [-dsoNEx] publish_address {172.17.0.2:9300}, bound_addresses {0.0.0.0:9300}
[2023-01-19T03:57:08,962][WARN ][o.e.b.BootstrapChecks    ] [-dsoNEx] max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2023-01-19T03:57:08,998][INFO ][o.e.x.s.t.n.SecurityNetty4HttpServerTransport] [-dsoNEx] publish_address {172.17.0.2:9200}, bound_addresses {0.0.0.0:9200}
[2023-01-19T03:57:08,999][INFO ][o.e.n.Node               ] [-dsoNEx] started

But when I run CUrl, I am not able to connect.

$ curl 0.0.0.0:9200

enter image description here

When I issue the cUrl on 127.0.0.2.9200, I see the response

curl 127.0.0.2:9200

StatusCode        : 200
StatusDescription : OK
Content           : {
                      "name" : "-dsoNEx",
                      "cluster_name" : "docker-cluster",
                      "cluster_uuid" : "UzUGppOxQ5ePcxLNB49HvA",
                      "version" : {
                        "number" : "6.3.2",
                        "build_flavor" : "default",
                        "build_type" : "ta...
RawContent        : HTTP/1.1 200 OK
                    Content-Length: 494
                    Content-Type: application/json; charset=UTF-8

                    {
                      "name" : "-dsoNEx",
                      "cluster_name" : "docker-cluster",
                      "cluster_uuid" : "UzUGppOxQ5ePcxLNB49HvA",
                      "vers...
Forms             : {}
Headers           : {[Content-Length, 494], [Content-Type, application/json; charset=UTF-8]}
Images            : {}
InputFields       : {}
Links             : {}
ParsedHtml        : mshtml.HTMLDocumentClass
RawContentLength  : 494

Upvotes: 1

Views: 691

Answers (1)

AlphaBeta
AlphaBeta

Reputation: 320

Connecting to 0.0.0.0 does not make any sense, as it is not the address of your device. The 0.0.0.0:9200->9200/tcp output from docker means that the service is listening on all interfaces (i.e., 0.0.0.0). Thus you can connect via 127.0.0.1 or your public IP address from your network card, for instance.

Upvotes: 2

Related Questions