Add daemon option --default-shm-size

This fix fixes issue raised in 29492 where it was not
possible to specify a default `--default-shm-size` in daemon
configuration for each `docker run``.

The flag `--default-shm-size` which is reloadable, has been
added to the daemon configuation.
Related docs has been updated.

This fix fixes 29492.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
Yong Tang 2016-12-25 01:11:12 -08:00
parent 0e9401f84b
commit ab794c5579
2 changed files with 4 additions and 25 deletions

View File

@ -11,7 +11,6 @@ import (
"github.com/docker/docker/opts" "github.com/docker/docker/opts"
runconfigopts "github.com/docker/docker/runconfig/opts" runconfigopts "github.com/docker/docker/runconfig/opts"
"github.com/docker/go-connections/nat" "github.com/docker/go-connections/nat"
units "github.com/docker/go-units"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -19,26 +18,6 @@ type int64Value interface {
Value() int64 Value() int64
} }
type memBytes int64
func (m *memBytes) String() string {
return units.BytesSize(float64(m.Value()))
}
func (m *memBytes) Set(value string) error {
val, err := units.RAMInBytes(value)
*m = memBytes(val)
return err
}
func (m *memBytes) Type() string {
return "bytes"
}
func (m *memBytes) Value() int64 {
return int64(*m)
}
// PositiveDurationOpt is an option type for time.Duration that uses a pointer. // PositiveDurationOpt is an option type for time.Duration that uses a pointer.
// It bahave similarly to DurationOpt but only allows positive duration values. // It bahave similarly to DurationOpt but only allows positive duration values.
type PositiveDurationOpt struct { type PositiveDurationOpt struct {
@ -149,9 +128,9 @@ type updateOptions struct {
type resourceOptions struct { type resourceOptions struct {
limitCPU opts.NanoCPUs limitCPU opts.NanoCPUs
limitMemBytes memBytes limitMemBytes opts.MemBytes
resCPU opts.NanoCPUs resCPU opts.NanoCPUs
resMemBytes memBytes resMemBytes opts.MemBytes
} }
func (r *resourceOptions) ToResourceRequirements() *swarm.ResourceRequirements { func (r *resourceOptions) ToResourceRequirements() *swarm.ResourceRequirements {

View File

@ -11,12 +11,12 @@ import (
) )
func TestMemBytesString(t *testing.T) { func TestMemBytesString(t *testing.T) {
var mem memBytes = 1048576 var mem opts.MemBytes = 1048576
assert.Equal(t, mem.String(), "1 MiB") assert.Equal(t, mem.String(), "1 MiB")
} }
func TestMemBytesSetAndValue(t *testing.T) { func TestMemBytesSetAndValue(t *testing.T) {
var mem memBytes var mem opts.MemBytes
assert.NilError(t, mem.Set("5kb")) assert.NilError(t, mem.Set("5kb"))
assert.Equal(t, mem.Value(), int64(5120)) assert.Equal(t, mem.Value(), int64(5120))
} }