Skip to content

Commit

Permalink
Enable game server ip address allocation for macvlan driver.
Browse files Browse the repository at this point in the history
Issue:
For macvlan driver default docker config assign first available ip.
Game servers get ip assigned in order of container creation.

Solution proposal:
Wings support only one docker network for each game server.
To assign correct IP default allocation could be used.
Allocations doesn't limit IPs at all, admin could set desired game server container ip and port by default allocation.
  • Loading branch information
madpeteguy authored Jul 17, 2022
1 parent e1e7916 commit 2dd9c0a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion environment/docker/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,18 @@ func (e *Environment) Create() error {
NetworkMode: container.NetworkMode(config.Get().Docker.Network.Mode),
}

if _, err := e.client.ContainerCreate(context.Background(), conf, hostConf, nil, nil, e.Id); err != nil {
var netConf *network.NetworkingConfig = nil //In case when no networking config is needed set nil
if "macvlan" == config.Get().Docker.Network.Driver { //Generate networking config for macvlan driver
netConf = &network.NetworkingConfig{
EndpointsConfig: map[string]*network.EndpointSettings{
config.Get().Docker.Network.Name: { //Get network name from wings config
IPAddress: e.Config().Allocations().DefaultMapping.Ip, //Use default mapping ip address (wings support only one network per server)
},
},
}
}
// Pass the networkings configuration or nil if none required
if _, err := e.client.ContainerCreate(context.Background(), conf, hostConf, netConf, nil, e.Id); err != nil {
return errors.Wrap(err, "environment/docker: failed to create container")
}

Expand Down

0 comments on commit 2dd9c0a

Please sign in to comment.