Integrate limits on inspect

Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
This commit is contained in:
Ulysses Souza 2020-06-24 09:59:53 +02:00
parent 0a57fd7d5c
commit 1deb2b8b09
16 changed files with 363 additions and 154 deletions

View file

@ -4,8 +4,10 @@ Usage:
run [flags]
Flags:
--cpus float Number of CPUs (default 1)
-d, --detach Run container in background and print container ID (default true)
-l, --label stringArray Set meta data on a container
-m, --memory bytes Memory limit
--name string Assign a name to the container
-p, --publish stringArray Publish a container's port(s). [HOST_PORT:]CONTAINER_PORT
-v, --volume stringArray Volume. Ex: user:key@my_share:/absolute/path/to/target

View file

@ -4,6 +4,7 @@
"Image": "nginx",
"Command": "",
"CPUTime": 0,
"CPULimit": 0,
"MemoryUsage": 0,
"MemoryLimit": 0,
"PidsCurrent": 0,

View file

@ -21,11 +21,11 @@ import (
"strconv"
"strings"
"github.com/docker/cli/opts"
"github.com/docker/docker/pkg/namesgenerator"
"github.com/docker/go-connections/nat"
"github.com/docker/api/containers"
"github.com/docker/api/formatter"
)
// Opts contain run command options
@ -35,7 +35,7 @@ type Opts struct {
Labels []string
Volumes []string
Cpus float64
Memory opts.MemBytes
Memory formatter.MemBytes
}
// ToContainerConfig convert run options to a container configuration
@ -61,7 +61,7 @@ func (r *Opts) ToContainerConfig(image string) (containers.ContainerConfig, erro
Labels: labels,
Volumes: r.Volumes,
MemLimit: r.Memory,
CpuLimit: r.Cpus,
CPULimit: r.Cpus,
}, nil
}