Skip to content

Commit 14156e6

Browse files
committed
fix default-ulimits in daemon.json
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
1 parent 8865aaa commit 14156e6

3 files changed

Lines changed: 31 additions & 1 deletion

File tree

daemon/config_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (config *Config) InstallFlags(flags *pflag.FlagSet) {
7171

7272
// Then platform-specific install flags
7373
flags.BoolVar(&config.EnableSelinuxSupport, "selinux-enabled", false, "Enable selinux support")
74-
flags.Var(runconfigopts.NewUlimitOpt(&config.Ulimits), "default-ulimit", "Default ulimits for containers")
74+
flags.Var(runconfigopts.NewNamedUlimitOpt("default-ulimits", &config.Ulimits), "default-ulimit", "Default ulimits for containers")
7575
flags.BoolVar(&config.bridgeConfig.EnableIPTables, "iptables", true, "Enable addition of iptables rules")
7676
flags.BoolVar(&config.bridgeConfig.EnableIPForward, "ip-forward", true, "Enable net.ipv4.ip_forward")
7777
flags.BoolVar(&config.bridgeConfig.EnableIPMasq, "ip-masq", true, "Enable IP masquerading")

runconfig/opts/opts.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ import (
1010
fopts "github.com/docker/docker/opts"
1111
)
1212

13+
// NamedOption is an interface that list and map options
14+
// with names implement.
15+
type NamedOption interface {
16+
Name() string
17+
}
18+
1319
// ValidateAttach validates that the specified string is a valid attach option.
1420
func ValidateAttach(val string) (string, error) {
1521
s := strings.ToLower(val)

runconfig/opts/ulimit.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,27 @@ func (o *UlimitOpt) GetList() []*units.Ulimit {
5555
func (o *UlimitOpt) Type() string {
5656
return "ulimit"
5757
}
58+
59+
// NamedUlimitOpt defines a named map of Ulimits
60+
type NamedUlimitOpt struct {
61+
name string
62+
UlimitOpt
63+
}
64+
65+
var _ NamedOption = &NamedUlimitOpt{}
66+
67+
// NewNamedUlimitOpt creates a new NamedUlimitOpt
68+
func NewNamedUlimitOpt(name string, ref *map[string]*units.Ulimit) *NamedUlimitOpt {
69+
if ref == nil {
70+
ref = &map[string]*units.Ulimit{}
71+
}
72+
return &NamedUlimitOpt{
73+
name: name,
74+
UlimitOpt: *NewUlimitOpt(ref),
75+
}
76+
}
77+
78+
// Name returns the option name
79+
func (o *NamedUlimitOpt) Name() string {
80+
return o.name
81+
}

0 commit comments

Comments
 (0)