hook up global networks
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
|
||||
"docker.io/go-docker"
|
||||
"docker.io/go-docker/api/types"
|
||||
"docker.io/go-docker/api/types/network"
|
||||
"docker.io/go-docker/api/types/volume"
|
||||
)
|
||||
|
||||
@@ -214,6 +215,19 @@ func (e *Docker) create(ctx context.Context, spec *Spec, step *Step, output io.W
|
||||
return err
|
||||
}
|
||||
|
||||
// attach the container to user-defined networks.
|
||||
// primarily used to attach global user-defined networks.
|
||||
if step.Network == "" {
|
||||
for _, net := range step.Networks {
|
||||
err = e.client.NetworkConnect(ctx, net, step.ID, &network.EndpointSettings{
|
||||
Aliases: []string{net},
|
||||
})
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user