From 629abab4c0311feb7db023ffda4a3c7d99c1f8fc Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Wed, 28 Dec 2016 14:44:07 -0800 Subject: [PATCH] Update opts.MemBytes to disable default, and move `docker run/create/build` to use opts.MemBytes This fix made several updates: 1. Update opts.MemBytes so that default value will not show up. The reason is that in case a default value is decided by daemon, instead of client, we actually want to not show default value. 2. Move `docker run/create/build` to use opts.MemBytes for `--shm-size` This is to bring consistency between daemon and docker run 3. docs updates. Signed-off-by: Yong Tang --- opts/opts.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/opts/opts.go b/opts/opts.go index c7d6c291bb..3ae0fdb6b9 100644 --- a/opts/opts.go +++ b/opts/opts.go @@ -409,7 +409,13 @@ type MemBytes int64 // String returns the string format of the human readable memory bytes func (m *MemBytes) String() string { - return units.BytesSize(float64(m.Value())) + // NOTE: In spf13/pflag/flag.go, "0" is considered as "zero value" while "0 B" is not. + // We return "0" in case value is 0 here so that the default value is hidden. + // (Sometimes "default 0 B" is actually misleading) + if m.Value() != 0 { + return units.BytesSize(float64(m.Value())) + } + return "0" } // Set sets the value of the MemBytes by passing a string