求助: vm 虚拟机更换桥接模式后, docker 服务均无法访问
2021-08-05 13:29:14 +08:00
rationa1cuzz
不好放图,网卡以及 docker 运行详情如图
[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:1d:49:b7 brd ff:ff:ff:ff:ff:ff
inet 192.168.4.110/24 brd 192.168.4.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::473f:7d97:58c3:43c4/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:9b:11:a3:2f brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
inet6 fe80::42:9bff:fe11:a32f/64 scope link
valid_lft forever preferred_lft forever
5: vethb5b26d3@if4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default
link/ether fa:fc:a2:ac:1e:e3 brd ff:ff:ff:ff:ff:ff link-netnsid 1
inet6 fe80::f8fc:a2ff:feac:1ee3/64 scope link
valid_lft forever preferred_lft forever
7: veth3bacdb8@if6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default
link/ether 6a:83:4d:48:ab:08 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet6 fe80::6883:4dff:fe48:ab08/64 scope link
valid_lft forever preferred_lft forever
9: veth3e9d188@if8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default
link/ether 4e:09:b9:63:b4:56 brd ff:ff:ff:ff:ff:ff link-netnsid 2
inet6 fe80::4c09:b9ff:fe63:b456/64 scope link
valid_lft forever preferred_lft forever
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d5ddf490a257 jenkinsci/blueocean "/sbin/tini -- /usr/…" 9 days ago Up 55 minutes 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp, 50000/tcp jenkins
aa5facb8b0e4 redis "docker-entrypoint.s…" 2 weeks ago Up About an hour 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp redis
696c72bc1d24 mysql:5.7 "docker-entrypoint.s…" 2 weeks ago Up About an hour 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp mysql
[root@localhost ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
6 条回复
lysS
2021-08-05 13:50:47 +08:00
虚拟机能正常连网吗?
rationa1cuzz
2021-08-05 13:58:25 +08:00
@
lysS 可以 ping 通百度,我的电脑也可以正常连接到宿主机
大概网络拓扑 我 192.168.4.10 另一台物理机 192.168.4.100 [虚拟机(宿主机)192.168.4.110 ]
均可以正常连接
lysS
2021-08-05 14:37:48 +08:00
大概记得 docker 也是桥接
我猜:你的 VM 的虚拟机的同一端口同时和容器与主机桥接,估计是冲突了
换成 NAT 应该可以解决
推荐在 WSL 里装 docker
rationa1cuzz
2021-08-05 14:56:16 +08:00
@
lysS 我是从 nat 换过来的,nat 模式我就没有办法通过我的主机 ssh 到宿主机了
rationa1cuzz
2021-08-05 14:58:36 +08:00
@
lysS 你的意思是我虚拟机的 3306 既与主机桥接又和容器桥接冲突了是吗?但是我的 jenkins 8080 可以正常访问
rationa1cuzz
2021-08-05 15:17:08 +08:00
@
lysS 重新创了一个容器 4417:3306,按照冲突说法现在应该不对,此时我主机 4417---虚拟机 4417----容器 3306
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
https://www.v2ex.com/t/793832
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.