目标
你想与所有 lxc 容器共享主机网络。
通过输入以下命令检查容器的网络设置:
如果显示类似这样的内容:
+---------+----------+---------+-------------+---------+
| NAME | TYPE | MANAGED | DESCRIPTION | USED BY |
+---------+----------+---------+-------------+---------+
| docker0 | bridge | NO | | 0 |
+---------+----------+---------+-------------+---------+
| eth0 | physical | NO | | 0 |
+---------+----------+---------+-------------+---------+
解决方案
使用 LXD 的默认设置设置容器,为主机系统上所有连接到新创建的 lxdbr0 适配器的容器创建网络
并接受默认值:
Would you like to create a new local network bridge? (yes/no) [default=yes]:
What should the new bridge be called? [default=lxdbr0]:
并让你的容器已连接到主机上的 lxdbr0 网桥。
你现在可能会看到类似这样的内容。
lxc_network_list_after.txt
+---------+----------+---------+-------------+---------+
| NAME | TYPE | MANAGED | DESCRIPTION | USED BY |
+---------+----------+---------+-------------+---------+
| docker0 | bridge | NO | | 0 |
+---------+----------+---------+-------------+---------+
| eth0 | physical | NO | | 0 |
+---------+----------+---------+-------------+---------+
| lxdbr0 | bridge | YES | | 5 |
+---------+----------+---------+-------------+---------+
现在试试
lxc exec [mycontainer] /bin/bash
curl https://techoverflow.net
Check out similar posts by category:
Allgemein If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow