Linux Fedora 28 KDE上的Docker容器没有internet连接
从几周前开始,我一直在尝试修复我的新笔记本电脑Fedora28KDE台式机的一个问题 我有两个问题:Linux Fedora 28 KDE上的Docker容器没有internet连接,linux,docker,networking,Linux,Docker,Networking,从几周前开始,我一直在尝试修复我的新笔记本电脑Fedora28KDE台式机的一个问题 我有两个问题: 容器无法连接到internet 容器在/etc/hosts中看不到我的主机 我尝试了许多解决方案,禁用firewalld、刷新iptables、接受ip表中的所有连接、启用firewalld以及将网络区域更改为“受信任”!还使用daemon.json取消了iptables!它仍然不起作用 任何人都可以帮忙,这对我来说都是一场噩梦 更新#1: 即使当我试图建立一个形象,它不能访问互联网的某些原因!
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
当我打开防火墙服务并将wifi连接区域设置为“外部”时,现在容器/码头工人可以访问互联网,但服务不能相互访问
这是我的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
$ curl api.nabed.local
curl: (7) Failed to connect to api.nabed.local port 80: Connection timed out
CMS容器内部:
$ curl cms.nabed.local
curl: (7) Failed to connect to cms.nabed.local port 80: Connection timed out
$ curl api.nabed.local
curl: (7) Failed to connect to api.nabed.local port 80: Connection timed out
更新#3:
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
我可以通过将我的主机放在YAML文件中的额外主机选项来解决此问题
然后将我的所有网络切换到“受信任的”“模式
然后重新启动docker和Networkmanager
注意:对于投票结束此问题的ppl,请尝试“帮助”尝试非常脏的解决方案-在主机网络中启动容器-docker运行参数
--net=host
我想,还会有更好的解决方案,但您没有提供详细信息,说明如何启动容器以及哪个网络可用于容器