Skip to content

Commit

Permalink
Add network option (#137)
Browse files Browse the repository at this point in the history
Signed-off-by: Chang Fu Chiao <[email protected]>
  • Loading branch information
fuchiao authored and arekkas committed Aug 22, 2018
1 parent bb9a1e0 commit 9f1141b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions dockertest.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ type RunOptions struct {
CapAdd []string
SecurityOpt []string
WorkingDir string
NetworkID string
Labels map[string]string
Auth dc.AuthConfiguration
PortBindings map[dc.Port][]dc.PortBinding
Expand Down Expand Up @@ -243,6 +244,13 @@ func (d *Pool) RunWithOptions(opts *RunOptions) (*Resource, error) {
tag = "latest"
}

networkingConfig := dc.NetworkingConfig{
EndpointsConfig: map[string]*dc.EndpointConfig{},
}
if opts.NetworkID != "" {
networkingConfig.EndpointsConfig[opts.NetworkID] = &dc.EndpointConfig{}
}

_, err := d.Client.InspectImage(fmt.Sprintf("%s:%s", repository, tag))
if err != nil {
if err := d.Client.PullImage(dc.PullImageOptions{
Expand Down Expand Up @@ -277,6 +285,7 @@ func (d *Pool) RunWithOptions(opts *RunOptions) (*Resource, error) {
SecurityOpt: opts.SecurityOpt,
Privileged: opts.Privileged,
},
NetworkingConfig: &networkingConfig,
})
if err != nil {
return nil, errors.Wrap(err, "")
Expand Down

0 comments on commit 9f1141b

Please sign in to comment.