Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,7 @@ func (p *DockerProvider) CreateNetwork(ctx context.Context, req NetworkRequest)

nc := network.CreateOptions{
Driver: req.Driver,
Options: req.DriverOptions,
Internal: req.Internal,
EnableIPv6: req.EnableIPv6,
Attachable: req.Attachable,
Expand Down
1 change: 1 addition & 0 deletions docs/features/networking.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Then, you can create a network using the `network.New` function. This function r
- `WithAttachable()`
- `WithCheckDuplicate()`
- `WithDriver(driver string)`
- `WithDriverOptions(options map[string]string)`
- `WithEnableIPv6()`
- `WithInternal()`
- `WithLabels(labels map[string]string)`
Expand Down
1 change: 1 addition & 0 deletions network.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func (n DefaultNetwork) ApplyDockerTo(opts *DockerProviderOptions) {
// NetworkRequest represents the parameters used to get a network
type NetworkRequest struct {
Driver string
DriverOptions map[string]string
CheckDuplicate bool // Deprecated: CheckDuplicate is deprecated since API v1.44, but it defaults to true when sent by the client package to older daemons.
Internal bool
EnableIPv6 *bool
Expand Down
24 changes: 17 additions & 7 deletions network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ func New(ctx context.Context, opts ...NetworkCustomizer) (*testcontainers.Docker

//nolint:staticcheck
netReq := testcontainers.NetworkRequest{
Driver: nc.Driver,
Internal: nc.Internal,
EnableIPv6: nc.EnableIPv6,
Name: uuid.NewString(),
Labels: nc.Labels,
Attachable: nc.Attachable,
IPAM: nc.IPAM,
Driver: nc.Driver,
DriverOptions: nc.Options,
Internal: nc.Internal,
EnableIPv6: nc.EnableIPv6,
Name: uuid.NewString(),
Labels: nc.Labels,
Attachable: nc.Attachable,
IPAM: nc.IPAM,
}

//nolint:staticcheck
Expand Down Expand Up @@ -96,6 +97,15 @@ func WithDriver(driver string) CustomizeNetworkOption {
}
}

// WithDriverOptions allows to set driver options.
func WithDriverOptions(options map[string]string) CustomizeNetworkOption {
return func(original *network.CreateOptions) error {
original.Options = options

return nil
}
}

// WithEnableIPv6 allows to set the network as IPv6 enabled.
// Please use this option if and only if IPv6 is enabled on the Docker daemon.
func WithEnableIPv6() CustomizeNetworkOption {
Expand Down
Loading