Skip to content
Closed
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
12 changes: 10 additions & 2 deletions env.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,16 @@ type environmentOptions struct {
verbose bool
name string

volumes []string
cpus string
volumes []string
cpus string
dnsServer string
}

// WithDNS sets DNS server to be used by the environment.
func WithDNS(dnsServer string) EnvironmentOption {
return func(o *environmentOptions) {
o.dnsServer = dnsServer
}
}

func WithCPUs(cpus string) EnvironmentOption {
Expand Down
9 changes: 8 additions & 1 deletion env_docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ type DockerEnvironment struct {

hostAddr string
dockerVolumes []string
cpus string

dnsServer string
cpus string

registered map[string]struct{}
listeners []EnvironmentListener
Expand Down Expand Up @@ -115,6 +117,7 @@ func New(opts ...EnvironmentOption) (_ *DockerEnvironment, err error) {
registered: map[string]struct{}{},
dockerVolumes: e.volumes,
cpus: e.cpus,
dnsServer: e.dnsServer,
}

// Force a shutdown in order to cleanup from a spurious situation in case
Expand Down Expand Up @@ -318,6 +321,10 @@ func (e *DockerEnvironment) buildDockerRunArgs(name string, ports map[string]int
args = append(args, "--privileged")
}

if e.dnsServer != "" {
args = append(args, "--dns", e.dnsServer)
}

for _, c := range opts.Capabilities {
args = append(args, "--cap-add", string(c))
}
Expand Down
Loading