Docker Community Forums

Share and learn in the Docker community.

Get error 'curl: (56) Recv failure: Connection reset by peer' when use docker-compose to install ELK

I try to run Elastic and Kibana with docker-compose follow the guide,
run-stack-docker

Everything seems ok,

[root@VM-48-14-centos ~/docker-compose-elasticsearch-kibana]# docker-compose up -d
Creating network "docker-compose-elasticsearch-kibana_elastic" with driver "bridge"
Creating kib01 ... done
Creating es03  ... done
Creating es01  ... done
Creating es02  ... done
[root@VM-48-14-centos ~/docker-compose-elasticsearch-kibana]# docker-compose ps -a
Name               Command               State                         Ports                       
---------------------------------------------------------------------------------------------------
es01    /bin/tini -- /usr/local/bi ...   Up      0.0.0.0:9200->9200/tcp,:::9200->9200/tcp, 9300/tcp
es02    /bin/tini -- /usr/local/bi ...   Up      9200/tcp, 9300/tcp                                
es03    /bin/tini -- /usr/local/bi ...   Up      9200/tcp, 9300/tcp                                
kib01   /bin/tini -- /usr/local/bi ...   Up      0.0.0.0:5601->5601/tcp,:::5601->5601/tcp          
[root@VM-48-14-centos ~/docker-compose-elasticsearch-kibana]# netstat -atpn 
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.172:56000         0.0.0.0:*               LISTEN      1217/sshd           
tcp        0      0 0.0.0.0:36000           0.0.0.0:*               LISTEN      1773/sshd           
tcp        0      0 0.0.0.0:9200            0.0.0.0:*               LISTEN      528080/docker-proxy 
tcp        0      0 0.0.0.0:5601            0.0.0.0:*               LISTEN      528059/docker-proxy 
tcp        0      0 172.16.48.14:47692      169.254.0.55:5574       ESTABLISHED 1985/YDService      
tcp        0      0 172.16.48.14:49372      169.254.0.23:80         TIME_WAIT   -                   
tcp        0      1 172.16.48.14:39066      10.133.40.10:9922       SYN_SENT    3254/agent          
tcp        0      0 172.16.48.14:42255      169.254.0.35:9988       ESTABLISHED 1887/secu-tcs-agent 
tcp        0      0 172.16.48.14:49355      169.254.0.23:80         TIME_WAIT   -                   
tcp        0    400 172.16.48.14:36000      113.108.77.61:4941      ESTABLISHED 331341/sshd: root@p 
tcp6       0      0 :::9200                 :::*                    LISTEN      528086/docker-proxy 
tcp6       0      0 :::5601                 :::*                    LISTEN      528066/docker-proxy 
[root@VM-48-14-centos ~/docker-compose-elasticsearch-kibana]#
  • But, when I try to access es and Kibana, gets error 'curl: (56) Recv failure: Connection reset by peer’

[root@VM-48-14-centos ~/docker-compose-elasticsearch-kibana]# curl 127.0.0.1:9200/_cluster/health?pretty
curl: (56) Recv failure: Connection reset by peer
[root@VM-48-14-centos ~/docker-compose-elasticsearch-kibana]# curl 127.0.0.1:5601
curl: (56) Recv failure: Connection reset by peer
[root@VM-48-14-centos ~/docker-compose-elasticsearch-kibana]#

I have entered the container, and access the above URL, nothing unusual,

[root@31d8357fb005 elasticsearch]# curl -X GET "0.0.0.0:9200"
{
  "name" : "es01",
  "cluster_name" : "es-docker-cluster",
  "cluster_uuid" : "pQGATR3HTOmS1YQCMnzf8Q",
  "version" : {
"number" : "7.13.0",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "5ca8591c6fcdb1260ce95b08a8e023559635c6f3",
"build_date" : "2021-05-19T22:22:26.081971330Z",
"build_snapshot" : false,
"lucene_version" : "8.8.2",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
[root@31d8357fb005 elasticsearch]# 

Where is the problem?
Why can’t I access es and Kibana on docker host?


other information,

[root@VM-48-14-centos ~/docker-compose-elasticsearch-kibana]# docker version
Client: Docker Engine - Community
 Version:           20.10.6
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        370c289
 Built:             Fri Apr  9 22:45:33 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.6
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       8728dd2
  Built:            Fri Apr  9 22:43:57 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc:
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
[root@VM-48-14-centos ~/docker-compose-elasticsearch-kibana]# docker-compose version
docker-compose version 1.29.2, build 5becea4c
docker-py version: 5.0.0
CPython version: 3.7.10
OpenSSL version: OpenSSL 1.1.0l  10 Sep 2019
[root@VM-48-14-centos ~/docker-compose-elasticsearch-kibana]# uname -a
Linux VM-48-14-centos 3.10.107-1-tlinux2_kvm_guest-0052 #1 SMP Wed Jan 15 18:42:19 CST 2020 x86_64 x86_64 x86_64 GNU/Linux
[root@VM-48-14-centos ~/docker-compose-elasticsearch-kibana]#

Have you set “SERVER_HOST” env in your container?