docker端口访问不了(docker设置了端口映射,不能访问的解决方案)
类别:服务器 浏览量:260
时间:2021-10-23 10:27:59 docker端口访问不了
docker设置了端口映射,不能访问的解决方案#docker ps 查看, 所有端口都 做了映射
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 764b158ba491 open-falcon-plus-02:v-daiyi-01 "/bin/bash" 2 days ago Up 3 hours 0.0.0.0:4444->4444/tcp, 0.0.0.0:6030-6031->6030-6031/tcp, 0.0.0.0:6070-6071->6070-6071/tcp, 0.0.0.0:6080-6081->6080-6081/tcp, 0.0.0.0:8080-8081->8080-8081/tcp, 0.0.0.0:8433->8433/tcp, 0.0.0.0:9912->9912/tcp, 0.0.0.0:14444->14444/tcp, 0.0.0.0:16060->16060/tcp, 0.0.0.0:18433->18433/tcp, 8082/tcp open-falcon-plus-daiyi-01
#但是查看日志
tail -40 /home/work/open-falcon/agent/logs/agent.log
test@ubuntu-10:/tmp/bak$ tail -40 /home/work/open-falcon/agent/logs/agent.log 2018/10/14 20:27:09 transfer.go:48: call Transfer.Update fail: &{{2 1} <nil> 10.0.10.103:8433 1s} dial tcp 10.0.10.103:8433: getsockopt: connection refused 2018/10/14 20:27:09 var.go:95: <= <Total=0, Invalid:0, Latency=0ms, Message:> 2018/10/14 20:27:09 rpc.go:41: dial 10.0.10.103:8433 fail: dial tcp 10.0.10.103:8433: getsockopt: connection refused 2018/10/14 20:27:11 rpc.go:41: dial 10.0.10.103:8433 fail: dial tcp 10.0.10.103:8433: getsockopt: connection refused 2018/10/14 20:27:15 rpc.go:41: dial 10.0.10.103:8433 fail: dial tcp 10.0.10.103:8433: getsockopt: connection refused 2018/10/14 20:27:23 rpc.go:41: dial 10.0.10.103:8433 fail: dial tcp 10.0.10.103:8433: getsockopt: connection refused 2018/10/14 20:27:23 transfer.go:48: call Transfer.Update fail: &{{0 0} <nil> 10.0.10.103:8433 1s} dial tcp 10.0.10.103:8433: getsockopt: connection refused 2018/10/14 20:27:23 var.go:95: <= <Total=0, Invalid:0, Latency=0ms, Message:> 2018/10/14 20:27:41 var.go:88: => <Total=92> <Endpoint:ubuntu, Metric:agent.alive, Type:GAUGE, Tags:, Step:60, Time:1539574061, Value:1> 2018/10/14 20:27:41 var.go:88: => <Total=5> <Endpoint:ubuntu, Metric:df.bytes.free.percent, Type:GAUGE, Tags:mount=/,fstype=ext4, Step:60, Time:1539574061, Value:67.01861018345224>
但是无法访问
原因:docker里面的host不能配置127.0.0.1 或者192.168.0.1 或则宿主机器将无法访问端口
修改配置文件—(涉及到的,需要外部访问的都需要修改)
[root@ubuntu-10 open-falcon]# vim transfer/config/cfg.json { "debug": true, "minStep": 30, "http": { "enabled": true, "listen": "0.0.0.0:6060" }, "rpc": { "enabled": true, "listen": "0.0.0.0:8433" **#此处监听外面8433. 改成0.0.0.0** }, "socket": { "enabled": true, "listen": "0.0.0.0:4444", "timeout": 3600 }, "judge": { "enabled": true, "batch": 200, "connTimeout": 1000, "callTimeout": 5000, "maxConns": 32, "maxIdle": 32, "replicas": 500, "cluster": { "judge-00" : "127.0.0.1:6080" } }, "graph": { "enabled": true, "batch": 200, "connTimeout": 1000, "callTimeout": 5000, "maxConns": 32, "maxIdle": 32, "replicas": 500, "cluster": { "graph-00" : "127.0.0.1:6070" } }, "tsdb": { "enabled": false, "batch": 200, "connTimeout": 1000, "callTimeout": 5000, "maxConns": 32, "maxIdle": 32, "retry": 3, "address": "127.0.0.1:8088" }
修改好之后重启 docker里的服务
[root@ubuntu-10 open-falcon]# ./open-falcon restart transfer
再次查看日志
test@ubuntu-10:/tmp/bak$ tail -40 /home/work/open-falcon/agent/logs/agent.log 2018/10/15 02:52:48 var.go:88: => <Total=1> <Endpoint:test-endpoint, Metric:test-metric-97, Type:GAUGE, Tags:idc=lgi-test,loc=beijing-test, Step:20, Time:1539597168, Value:33> 2018/10/15 02:52:48 var.go:95: <= <Total=1, Invalid:0, Latency=0ms, Message:ok> 2018/10/15 02:52:48 var.go:88: => <Total=1> <Endpoint:test-endpoint, Metric:test-metric-97, Type:GAUGE, Tags:idc=lgi-test,loc=beijing-test, Step:20, Time:1539597168, Value:33> 2018/10/15 02:52:48 var.go:95: <= <Total=1, Invalid:0, Latency=0ms, Message:ok> 2018/10/15 02:52:48 var.go:88: => <Total=1> <Endpoint:test-endpoint, Metric:test-metric-97, Type:GAUGE, Tags:idc=lgi-test,loc=beijing-test, Step:20, Time:1539597168, Value:33> 2018/10/15 02:52:48 var.go:95: <= <Total=1, Invalid:0, Latency=0ms, Message:ok> #连接成功,数据传入。
查看端口的连接性
test@ubuntu-10:/tmp/bak$ telnet 10.0.10.103 8433 Trying 10.0.10.103... Connected to 10.0.10.103. Escape character is '^]'. #这就是ok的
好啦~ 可以连接成功。
补充:docker 镜像启动成功但是无法访问
解决办法:vi /etc/sysctl.conf 或者
vi /usr/lib/sysctl.d/00-system.conf 添加如下代码:
net.ipv4.ip_forward=1
重启network服务
systemctl restart network 查看是否修改成功
sysctl net.ipv4.ip_forward 如果返回为“net.ipv4.ip_forward = 1”则表示成功了
以上为个人经验,希望能给大家一个参考,也希望大家多多支持开心学习网。如有错误或未考虑完全的地方,望不吝赐教。
您可能感兴趣
- docker-compose 原理(详解docker compose 用法)
- docker-compose启动单个容器(docker-compose快速搭建docker私有仓库的步骤)
- docker容器默认内存大小(Docker 修改docker存储位置 修改容器镜像大小限制操作)
- docker配置阿里云镜像(Docker镜像的制作,上传,拉取和部署操作利用阿里云)
- dockerip访问限制(docker win ping 不通容器 避坑指南)
- docker查看容器教程(如何使用docker对容器资源进行限制)
- docker镜像怎么用(Docker和镜像的操作方法)
- docker swarm管理(Docker Swarm 服务编排之命令详解)
- docker启动sqlserver(用docker运行postgreSQL的方法步骤)
- docker端口访问不了(docker设置了端口映射,不能访问的解决方案)
- 配置阿里云docker镜像地址(Docker配置阿里云镜像加速pull的实现)
- docker进入容器的方法(在docker容器中安装vi命令的简单操作)
- docker配置自己的环境(docker可视化工具Portainer部署并汉化的操作)
- docker容器启动执行多条命令(详解Shell脚本控制docker容器启动顺序)
- docker nginx 配置详解(Docker 如何安装 Nginx)
- docker启动k8s(k3d入门指南之在Docker中运行K3s的详细教程)
- 这支 奇兵队 腕大 有范儿还各怀绝技,毒贩杀人犯见了都要仓皇而逃(这支奇兵队腕大)
- 雄藩崛起 奇兵队与幕末长州藩军事改革(雄藩崛起奇兵队与幕末长州藩军事改革)
- 九月初,爱如蜜糖,甜到心扉,迷恋彼此,一日不见兮,思之若狂(九月初爱如蜜糖)
- ()
- 对你思念入骨的女人,跟你见面时会有这几种表现,藏都藏不住(对你思念入骨的女人)
- 纳兰性德绝美作,一场重逢,成就最后一首称得上惊艳的《如梦令》(纳兰性德绝美作)
热门推荐
排行榜
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9