Only use bridge if available to prevent container startup failures

LXC doesn't start the container when the configured network interface
(the bridge in this case) is not available.
This commit is contained in:
Simon Fels 2016-12-04 11:53:58 +01:00
commit b31d79ca08

View file

@ -113,9 +113,11 @@ void LxcContainer::start(const Configuration &configuration) {
"lxc.logfile",
utils::string_format("%s/container.log", config::log_path()).c_str());
set_config_item("lxc.network.type", "veth");
set_config_item("lxc.network.flags", "up");
set_config_item("lxc.network.link", "anboxbr0");
if (fs::exists("/sys/class/net/anboxbr0")) {
set_config_item("lxc.network.type", "veth");
set_config_item("lxc.network.flags", "up");
set_config_item("lxc.network.link", "anboxbr0");
}
#if 0
// Android uses namespaces as well so we have to allow nested namespaces for LXC