telnet:无法连接到远程主机:尝试连接正在运行的 docker 映像时连接被拒绝 [英] telnet: Unable to connect to remote host: Connection refused when trying to connect running docker image

查看:33
本文介绍了telnet:无法连接到远程主机:尝试连接正在运行的 docker 映像时连接被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在服务器上运行 ubuntu 18.04.我有一个在 docker 上运行的 JasperServer 图像.我正在尝试从我的系统访问它.但它抛出以下错误:

I am having ubuntu 18.04 running on a server. I am got a JasperServer image running on docker in it. I am trying to access it from my system. But it throws the following error:

jamshaid@jamshaid:~$ telnet my_server_address 9095
Trying my_server_ip...

telnet: Unable to connect to remote host: Connection refused

这是 sudo docker ps -a

CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                                           NAMES
69c31ba800ab        bitnami/jasperreports   "/app-entrypoint.sh …"   5 hours ago         Up 5 hours          0.0.0.0:9095->8080/tcp, 0.0.0.0:443->8443/tcp   ceyedev_jasperreports_1
2a7cb72da0c7        bitnami/mariadb:10.3    "/opt/bitnami/script…"   5 hours ago         Up 5 hours          0.0.0.0:3306->3306/tcp                          ceyedev_mariadb_1

如果我在本地主机上 telnet,它会连接然后连接关闭,这意味着它运行良好.这是我从 localhost telnet 时的输出:

if I telnet on localhost, it connects and then connection closes which means it is running well. Here is the output when I telnet it from localhost:

ceyedev@ub18servertiny:~$ telnet localhost 9095
Trying ::1...
Connected to localhost.localdomain.
Escape character is '^]'.
Connection closed by foreign host.

这里是 docker-compose 文件

Here is the docker-compose file

version: '2'
services:
  mariadb:
    restart: always
    image: 'bitnami/mariadb:10.3'
    environment:
      - MARIADB_USER=bn_jasperreports
      - MARIADB_DATABASE=bitnami_jasperreports
      - ALLOW_EMPTY_PASSWORD=yes
    ports:
      - 3306:3306      
    volumes:
      - 'mariadb_data:/bitnami'
  jasperreports:
    restart: always
    image: 'bitnami/jasperreports'
    environment:
      - MARIADB_HOST=mariadb
      - MARIADB_PORT_NUMBER=3306
      - JASPERREPORTS_DATABASE_USER=bn_jasperreports
      - JASPERREPORTS_DATABASE_NAME=bitnami_jasperreports
      - ALLOW_EMPTY_PASSWORD=yes
    ports:
      - '9095:8080'
      - '443:8443'
    volumes:
      - 'jasperreports_data:/bitnami'
    depends_on:
      - mariadb
volumes:
  mariadb_data:
    driver: local
  jasperreports_data:
    driver: local 

这是sudo docker logs container_id_for_jasper
的输出

我可以从本地机器 telnet 其他端口,但是这个端口有问题.有任何想法吗?谢谢

I can telnet other ports from my local machine but having an issue with this one. Any ideas? thanks

从答案中保留第 2 项的观点,我执行了以下命令,发现 9095 是由服务器分配的.有什么想法吗?

keeping in the view of bullet 2 from answers, I executed the below command and found that 9095 is allocated by the server. Any ideas, please?

ceyedev@ub18servertiny:~$ netstat -atn
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN     
tcp        0    244 10.0.114.15:22          182.185.223.147:54326   ESTABLISHED
tcp6       0      0 :::22                   :::*                    LISTEN     
tcp6       0      0 ::1:5432                :::*                    LISTEN     
tcp6       0      0 :::443                  :::*                    LISTEN     
tcp6       0      0 :::9095                 :::*                    LISTEN     
tcp6       0      0 :::3306                 :::*                    LISTEN     

推荐答案

根据你的问题,你知道:

Based on your question, you know:

  • Docker 容器正在运行
  • Docker 容器正在侦听端口 9095
  • 从 Linux 服务器到 docker 容器的 telnet 正在运行
  • 从 Internet 某处的其他客户端到 docker 容器的 telnet 不工作

我猜您的 Ubuntu 服务器不接受来自 Internet 端口 9095 上的传入请求.这可能有很多原因:

I guess your Ubuntu server is not accepting incoming requests from Internet on port 9095. There can be many reasons for that:

  • 您的服务器有防火墙设置,会阻止连接
  • 您的服务器没有将端口 9095 发布到 Internet
  • 您的客户端在使用端口 9095 时无法访问互联网

所以我会调查这些方面.
docker 部分似乎没问题,因为 telnet 到 localhost 正在工作.

So I would investigate these aspects.
The docker part seems to be ok, because telnet to localhost is working.

这篇关于telnet:无法连接到远程主机:尝试连接正在运行的 docker 映像时连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆