Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for specifying sysctls in run options #480

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ containerRunOptions:
- OTHER_SECRET_BAR
capabilities: # Add list of Linux capabilities (--cap-add)
- NET_BIND_SERVICE
sysctls:
net.core.somaxconn: "1024"
net.ipv4.tcp_max_syn_backlog: "4096"
bindMounts: # Bind mount a volume (--volume, -v)
- /etc/example/dir:/etc/dir
```
Expand Down
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