@@ -26,6 +26,8 @@ type runOptions struct {
2626 image string
2727 machines []string
2828 memory dockeropts.MemBytes
29+ memoryReservation dockeropts.MemBytes
30+ cpuReservation dockeropts.NanoCPUs
2931 mode string
3032 name string
3133 privileged bool
@@ -62,6 +64,8 @@ func NewRunCommand() *cobra.Command {
6264 cmd .Flags ().VarP (& opts .cpu , "cpu" , "" ,
6365 "Maximum number of CPU cores a service container can use. Fractional values are allowed: " +
6466 "0.5 for half a core or 2.25 for two and a quarter cores." )
67+ cmd .Flags ().Var (& opts .cpuReservation , "reserve-cpu" ,
68+ "Minimum CPU cores to reserve for placement (nanocores). Fractional values are allowed, e.g. 0.5 for half a core." )
6569 cmd .Flags ().StringVar (& opts .entrypoint , "entrypoint" , "" ,
6670 "Overwrite the default ENTRYPOINT of the image. Pass an empty string \" \" to reset it." )
6771 cmd .Flags ().StringSliceVarP (& opts .env , "env" , "e" , nil ,
@@ -78,6 +82,8 @@ func NewRunCommand() *cobra.Command {
7882 "Maximum amount of memory a service container can use. Value is a positive integer with optional unit suffix " +
7983 "(b, k, m, g). Default unit is bytes if no suffix specified.\n " +
8084 "Examples: 1073741824, 1024m, 1g (all equal 1 gibibyte)" )
85+ cmd .Flags ().Var (& opts .memoryReservation , "reserve-memory" ,
86+ "Minimum memory to reserve for placement. Value is a positive integer with optional unit suffix (b, k, m, g)." )
8187 cmd .Flags ().StringVarP (& opts .name , "name" , "n" , "" ,
8288 "Assign a name to the service. A random name is generated if not specified." )
8389 cmd .Flags ().BoolVar (& opts .privileged , "privileged" , false ,
@@ -210,8 +216,10 @@ func prepareServiceSpec(opts runOptions) (api.ServiceSpec, error) {
210216 Privileged : opts .privileged ,
211217 PullPolicy : opts .pull ,
212218 Resources : api.ContainerResources {
213- CPU : opts .cpu .Value (),
214- Memory : opts .memory .Value (),
219+ CPU : opts .cpu .Value (),
220+ Memory : opts .memory .Value (),
221+ CPUReservation : opts .cpuReservation .Value (),
222+ MemoryReservation : opts .memoryReservation .Value (),
215223 },
216224 User : opts .user ,
217225 VolumeMounts : mounts ,
0 commit comments