【发布时间】:2018-10-02 21:46:58
【问题描述】:
几周以来,我一直在尝试使用 Fedora 28 KDE 桌面解决我的新笔记本电脑上的一个问题!
我有两个问题:
- 容器无法连接到互联网
- 容器在 /etc/hosts 中看不到我的主机
我尝试了很多解决方案,禁用 firewalld、flusing iptables、接受 ip 表中的所有连接、启用 firewalld 并将网络区域更改为“受信任”!还使用 daemon.json 禁用了 iptables!还是不行!!
请任何人帮忙,这对我来说简直就是一场噩梦!
更新 #1:
即使我尝试构建映像,由于某种原因它也无法访问互联网!,似乎 docker 级别的问题不仅仅是容器! 我试图禁用防火墙或更改区域,我还将所有连接设置为“受信任”区域
有人可以帮忙吗?
更新 #2:
当我打开 firewalld 服务并将 wifi 连接区域设置为“外部”时,容器/docker 可以访问互联网,但服务无法相互访问
这是我的 yml 文件:
version: "3.4"
services:
nginx:
image: nginx
ports:
- "80:80"
- "443:443"
deploy:
mode: replicated
replicas: 1
networks:
nabed: {}
volumes:
- "../nginx/etc/nginx/conf.d:/etc/nginx/conf.d"
- "../nginx/etc/nginx/ssl:/etc/nginx/ssl"
api:
image: nabed_backend:dev
hostname: api
command: api
extra_hosts:
- "nabed.local:172.17.0.1"
- "cms.nabed.local:172.17.0.1"
deploy:
mode: replicated
replicas: 1
env_file: .api.env
networks:
nabed: {}
cms:
image: nabedd/cms:master
hostname: cms
extra_hosts:
- "nabed.local:172.17.0.1"
- "api.nabed.local:172.17.0.1"
deploy:
mode: replicated
replicas: 1
env_file: .cms.env
volumes:
- "../admin-panel:/admin-panel"
networks:
nabed: {}
networks:
nabed:
driver: overlay
API 容器内:
$ curl cms.nabed.local
curl: (7) Failed to connect to cms.nabed.local port 80: Connection timed out
CMS 容器内:
$ curl api.nabed.local
curl: (7) Failed to connect to api.nabed.local port 80: Connection timed out
更新 #3:
我可以通过将我的主机放入我的 YAML 文件中的 extra_hosts 选项来解决此问题 然后将我的所有网络都设置为“trusted”模式 然后重启 docker 和 Networkmanager
注意:对于投票结束此问题的人,请尝试帮助
【问题讨论】:
标签: linux docker networking