diff --git a/environment/docker/container.go b/environment/docker/container.go index 8f059638..432a1240 100644 --- a/environment/docker/container.go +++ b/environment/docker/container.go @@ -17,6 +17,7 @@ import ( "github.com/docker/docker/api/types/mount" "github.com/docker/docker/client" "github.com/docker/docker/daemon/logger/local" + "github.com/docker/docker/api/types/network" "github.com/pterodactyl/wings/config" "github.com/pterodactyl/wings/environment" @@ -264,7 +265,18 @@ func (e *Environment) Create() error { UsernsMode: container.UsernsMode(config.Get().Docker.UsernsMode), } - if _, err := e.client.ContainerCreate(ctx, 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(ctx, conf, hostConf, netConf, nil, e.Id); err != nil { return errors.Wrap(err, "environment/docker: failed to create container") }