【问题标题】:Docker container on Fedora 28 KDE have no internet connectionFedora 28 KDE 上的 Docker 容器没有互联网连接
【发布时间】:2018-10-02 21:46:58
【问题描述】:

几周以来,我一直在尝试使用 Fedora 28 KDE 桌面解决我的新笔记本电脑上的一个问题!

我有两个问题:

  1. 容器无法连接到互联网
  2. 容器在 /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”模式 然后重启 dockerNetworkmanager

注意:对于投票结束此问题的人,请尝试帮助

【问题讨论】:

    标签: linux docker networking


    【解决方案1】:

    尝试非常肮脏的解决方案 - 在主机网络中启动容器 - docker run 参数--net=host

    我想,还会有更好的解决方案,但您没有提供详细信息,您是如何启动容器以及哪个网络可用于您的容器。

    【讨论】:

      猜你喜欢
      • 2021-07-13
      • 2013-12-24
      • 2020-12-18
      • 2021-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多