fix: 解决容器设置 host 网络失败的问题 (#2582)

Refs #2550
This commit is contained in:
ssongliu 2023-10-17 17:56:25 +08:00 committed by wanghe-fit2cloud
parent 5f009152d3
commit 0449100e23

View File

@ -867,6 +867,10 @@ func loadConfigInfo(isCreate bool, req dto.ContainerOperate, oldContainer *types
config.Tty = req.Tty
if len(req.Network) != 0 {
switch req.Network {
case "host", "none", "bridge":
hostConf.NetworkMode = container.NetworkMode(req.Network)
}
networkConf.EndpointsConfig = map[string]*network.EndpointSettings{req.Network: {}}
} else {
networkConf = network.NetworkingConfig{}