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

Refs #2550
This commit is contained in:
ssongliu 2023-10-17 17:56:25 +08:00 committed by GitHub
parent 3ff09c8b7a
commit 0f7ec06404
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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{}