Skip to content

Commit

Permalink
Add support for specifying sysctls in run options
Browse files Browse the repository at this point in the history
This adds a new "Sysctls" field to the ContainerRunOptions struct. This
matches the go-dockerclient definition and just gets passed through to
the docker HostConfig struct as-is.
  • Loading branch information
ciarand committed Dec 9, 2024
1 parent 66691b8 commit 7c964fe
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
5 changes: 5 additions & 0 deletions bazel/test/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ metadataTest:
value: "/test"
entrypoint: ["/custom_bin"]
cmd: ["--arg1", "--arg2"]

containerRunOptions:
sysctls:
net.core.somaxconn: "1024"
net.ipv4.tcp_max_syn_backlog: "4096"
4 changes: 3 additions & 1 deletion pkg/drivers/docker_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import (
"bufio"
"bytes"
"fmt"
"github.com/joho/godotenv"
"io"
"os"
"path"
"path/filepath"
"strings"

"github.com/joho/godotenv"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

Expand Down Expand Up @@ -69,6 +69,7 @@ func (d *DockerDriver) hostConfig() *docker.HostConfig {
Capabilities: d.runOpts.Capabilities,
Binds: d.runOpts.BindMounts,
Privileged: d.runOpts.Privileged,
Sysctls: d.runOpts.Sysctls,
Runtime: d.runtime,
}
}
Expand All @@ -77,6 +78,7 @@ func (d *DockerDriver) hostConfig() *docker.HostConfig {
Capabilities: d.runOpts.Capabilities,
Binds: d.runOpts.BindMounts,
Privileged: d.runOpts.Privileged,
Sysctls: d.runOpts.Sysctls,
}
}
if d.runtime != "" {
Expand Down
10 changes: 6 additions & 4 deletions pkg/types/unversioned/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ type Config struct {
type ContainerRunOptions struct {
User string
Privileged bool
TTY bool `yaml:"allocateTty"`
EnvVars []string `yaml:"envVars"`
EnvFile string `yaml:"envFile"`
TTY bool `yaml:"allocateTty"`
EnvVars []string `yaml:"envVars"`
EnvFile string `yaml:"envFile"`
Sysctls map[string]string `yaml:"sysctls"`
Capabilities []string
BindMounts []string `yaml:"bindMounts"`
}
Expand All @@ -61,7 +62,8 @@ func (opts *ContainerRunOptions) IsSet() bool {
len(opts.EnvFile) > 0 ||
(opts.EnvVars != nil && len(opts.EnvVars) > 0) ||
(opts.Capabilities != nil && len(opts.Capabilities) > 0) ||
(opts.BindMounts != nil && len(opts.BindMounts) > 0)
(opts.BindMounts != nil && len(opts.BindMounts) > 0) ||
len(opts.Sysctls) > 0
}

type TestResult struct {
Expand Down

0 comments on commit 7c964fe

Please sign in to comment.