代码之家  ›  专栏  ›  技术社区  ›  villintehaspam

在CentOS Docker容器中添加虚拟网卡

  •  0
  • villintehaspam  · 技术社区  · 6 年前

    我正在尝试将虚拟网络适配器添加到Docker容器中。即不尝试连接到本地计算机上的任何实际接口。

    我试过跑步 ifconfig 但无济于事:

    [root@240ae570546a /]# ifconfig eth0:1 10.0.0.10/24 up SIOCSIFADDR: Operation not permitted SIOCSIFFLAGS: Operation not permitted SIOCSIFFLAGS: Operation not permitted SIOCSIFNETMASK: Operation not permitted

    我还尝试将配置文件添加到 /etc/sysconfig/network-scripts/ 当我建造码头集装箱,但这似乎也不起作用。

    我的集装箱建在 centos:7 . 如何将虚拟NIC添加到容器中?

    1 回复  |  直到 6 年前
        1
  •  1
  •   villintehaspam    6 年前

    似乎我需要用 --cap-add=NET_ADMIN 命令行参数:

    docker run --cap-add=NET_ADMIN -it my_container /bin/bash