Signed-off-by: Elias Faxö <elias.faxo@gmail.com>
Elias Faxö authored on 2016/11/29 18:58:47... | ... |
@@ -506,6 +506,9 @@ definitions: |
506 | 506 |
Retries: |
507 | 507 |
description: "The number of consecutive failures needed to consider a container as unhealthy. 0 means inherit." |
508 | 508 |
type: "integer" |
509 |
+ StartPeriod: |
|
510 |
+ description: "Start period for the container to initialize before starting health-retries countdown in nanoseconds. 0 means inherit." |
|
511 |
+ type: "integer" |
|
509 | 512 |
|
510 | 513 |
HostConfig: |
511 | 514 |
description: "Container configuration that depends on the host we are running on" |
... | ... |
@@ -19,8 +19,9 @@ type HealthConfig struct { |
19 | 19 |
Test []string `json:",omitempty"` |
20 | 20 |
|
21 | 21 |
// Zero means to inherit. Durations are expressed as integer nanoseconds. |
22 |
- Interval time.Duration `json:",omitempty"` // Interval is the time to wait between checks. |
|
23 |
- Timeout time.Duration `json:",omitempty"` // Timeout is the time to wait before considering the check to have hung. |
|
22 |
+ Interval time.Duration `json:",omitempty"` // Interval is the time to wait between checks. |
|
23 |
+ Timeout time.Duration `json:",omitempty"` // Timeout is the time to wait before considering the check to have hung. |
|
24 |
+ StartPeriod time.Duration `json:",omitempty"` // The start period for the container to initialize before the retries starts to count down. |
|
24 | 25 |
|
25 | 26 |
// Retries is the number of consecutive failures needed to consider a container as unhealthy. |
26 | 27 |
// Zero means inherit. |
... | ... |
@@ -540,6 +540,7 @@ func healthcheck(b *Builder, args []string, attributes map[string]bool, original |
540 | 540 |
|
541 | 541 |
flInterval := b.flags.AddString("interval", "") |
542 | 542 |
flTimeout := b.flags.AddString("timeout", "") |
543 |
+ flStartPeriod := b.flags.AddString("start-period", "") |
|
543 | 544 |
flRetries := b.flags.AddString("retries", "") |
544 | 545 |
|
545 | 546 |
if err := b.flags.Parse(); err != nil { |
... | ... |
@@ -574,6 +575,12 @@ func healthcheck(b *Builder, args []string, attributes map[string]bool, original |
574 | 574 |
} |
575 | 575 |
healthcheck.Timeout = timeout |
576 | 576 |
|
577 |
+ startPeriod, err := parseOptInterval(flStartPeriod) |
|
578 |
+ if err != nil { |
|
579 |
+ return err |
|
580 |
+ } |
|
581 |
+ healthcheck.StartPeriod = startPeriod |
|
582 |
+ |
|
577 | 583 |
if flRetries.Value != "" { |
578 | 584 |
retries, err := strconv.ParseInt(flRetries.Value, 10, 32) |
579 | 585 |
if err != nil { |
... | ... |
@@ -113,6 +113,7 @@ type containerOptions struct { |
113 | 113 |
healthCmd string |
114 | 114 |
healthInterval time.Duration |
115 | 115 |
healthTimeout time.Duration |
116 |
+ healthStartPeriod time.Duration |
|
116 | 117 |
healthRetries int |
117 | 118 |
runtime string |
118 | 119 |
autoRemove bool |
... | ... |
@@ -232,6 +233,8 @@ func addFlags(flags *pflag.FlagSet) *containerOptions { |
232 | 232 |
flags.DurationVar(&copts.healthInterval, "health-interval", 0, "Time between running the check (ns|us|ms|s|m|h) (default 0s)") |
233 | 233 |
flags.IntVar(&copts.healthRetries, "health-retries", 0, "Consecutive failures needed to report unhealthy") |
234 | 234 |
flags.DurationVar(&copts.healthTimeout, "health-timeout", 0, "Maximum time to allow one check to run (ns|us|ms|s|m|h) (default 0s)") |
235 |
+ flags.DurationVar(&copts.healthStartPeriod, "health-start-period", 0, "Start period for the container to initialize before starting health-retries countdown (ns|us|ms|s|m|h) (default 0s)") |
|
236 |
+ flags.SetAnnotation("health-start-period", "version", []string{"1.29"}) |
|
235 | 237 |
flags.BoolVar(&copts.noHealthcheck, "no-healthcheck", false, "Disable any container-specified HEALTHCHECK") |
236 | 238 |
|
237 | 239 |
// Resource management |
... | ... |
@@ -464,6 +467,7 @@ func parse(flags *pflag.FlagSet, copts *containerOptions) (*containerConfig, err |
464 | 464 |
haveHealthSettings := copts.healthCmd != "" || |
465 | 465 |
copts.healthInterval != 0 || |
466 | 466 |
copts.healthTimeout != 0 || |
467 |
+ copts.healthStartPeriod != 0 || |
|
467 | 468 |
copts.healthRetries != 0 |
468 | 469 |
if copts.noHealthcheck { |
469 | 470 |
if haveHealthSettings { |
... | ... |
@@ -486,12 +490,16 @@ func parse(flags *pflag.FlagSet, copts *containerOptions) (*containerConfig, err |
486 | 486 |
if copts.healthRetries < 0 { |
487 | 487 |
return nil, errors.Errorf("--health-retries cannot be negative") |
488 | 488 |
} |
489 |
+ if copts.healthStartPeriod < 0 { |
|
490 |
+ return nil, fmt.Errorf("--health-start-period cannot be negative") |
|
491 |
+ } |
|
489 | 492 |
|
490 | 493 |
healthConfig = &container.HealthConfig{ |
491 |
- Test: probe, |
|
492 |
- Interval: copts.healthInterval, |
|
493 |
- Timeout: copts.healthTimeout, |
|
494 |
- Retries: copts.healthRetries, |
|
494 |
+ Test: probe, |
|
495 |
+ Interval: copts.healthInterval, |
|
496 |
+ Timeout: copts.healthTimeout, |
|
497 |
+ StartPeriod: copts.healthStartPeriod, |
|
498 |
+ Retries: copts.healthRetries, |
|
495 | 499 |
} |
496 | 500 |
} |
497 | 501 |
|
... | ... |
@@ -501,8 +501,8 @@ func TestParseHealth(t *testing.T) { |
501 | 501 |
checkError("--no-healthcheck conflicts with --health-* options", |
502 | 502 |
"--no-healthcheck", "--health-cmd=/check.sh -q", "img", "cmd") |
503 | 503 |
|
504 |
- health = checkOk("--health-timeout=2s", "--health-retries=3", "--health-interval=4.5s", "img", "cmd") |
|
505 |
- if health.Timeout != 2*time.Second || health.Retries != 3 || health.Interval != 4500*time.Millisecond { |
|
504 |
+ health = checkOk("--health-timeout=2s", "--health-retries=3", "--health-interval=4.5s", "--health-start-period=5s", "img", "cmd") |
|
505 |
+ if health.Timeout != 2*time.Second || health.Retries != 3 || health.Interval != 4500*time.Millisecond || health.StartPeriod != 5*time.Second { |
|
506 | 506 |
t.Fatalf("--health-*: got %#v", health) |
507 | 507 |
} |
508 | 508 |
} |
... | ... |
@@ -282,6 +282,7 @@ type healthCheckOptions struct { |
282 | 282 |
interval PositiveDurationOpt |
283 | 283 |
timeout PositiveDurationOpt |
284 | 284 |
retries int |
285 |
+ startPeriod PositiveDurationOpt |
|
285 | 286 |
noHealthcheck bool |
286 | 287 |
} |
287 | 288 |
|
... | ... |
@@ -301,18 +302,22 @@ func (opts *healthCheckOptions) toHealthConfig() (*container.HealthConfig, error |
301 | 301 |
if opts.cmd != "" { |
302 | 302 |
test = []string{"CMD-SHELL", opts.cmd} |
303 | 303 |
} |
304 |
- var interval, timeout time.Duration |
|
304 |
+ var interval, timeout, startPeriod time.Duration |
|
305 | 305 |
if ptr := opts.interval.Value(); ptr != nil { |
306 | 306 |
interval = *ptr |
307 | 307 |
} |
308 | 308 |
if ptr := opts.timeout.Value(); ptr != nil { |
309 | 309 |
timeout = *ptr |
310 | 310 |
} |
311 |
+ if ptr := opts.startPeriod.Value(); ptr != nil { |
|
312 |
+ startPeriod = *ptr |
|
313 |
+ } |
|
311 | 314 |
healthConfig = &container.HealthConfig{ |
312 |
- Test: test, |
|
313 |
- Interval: interval, |
|
314 |
- Timeout: timeout, |
|
315 |
- Retries: opts.retries, |
|
315 |
+ Test: test, |
|
316 |
+ Interval: interval, |
|
317 |
+ Timeout: timeout, |
|
318 |
+ Retries: opts.retries, |
|
319 |
+ StartPeriod: startPeriod, |
|
316 | 320 |
} |
317 | 321 |
} |
318 | 322 |
return healthConfig, nil |
... | ... |
@@ -555,6 +560,8 @@ func addServiceFlags(flags *pflag.FlagSet, opts *serviceOptions) { |
555 | 555 |
flags.SetAnnotation(flagHealthTimeout, "version", []string{"1.25"}) |
556 | 556 |
flags.IntVar(&opts.healthcheck.retries, flagHealthRetries, 0, "Consecutive failures needed to report unhealthy") |
557 | 557 |
flags.SetAnnotation(flagHealthRetries, "version", []string{"1.25"}) |
558 |
+ flags.Var(&opts.healthcheck.startPeriod, flagHealthStartPeriod, "Start period for the container to initialize before counting retries towards unstable (ns|us|ms|s|m|h)") |
|
559 |
+ flags.SetAnnotation(flagHealthStartPeriod, "version", []string{"1.29"}) |
|
558 | 560 |
flags.BoolVar(&opts.healthcheck.noHealthcheck, flagNoHealthcheck, false, "Disable any container-specified HEALTHCHECK") |
559 | 561 |
flags.SetAnnotation(flagNoHealthcheck, "version", []string{"1.25"}) |
560 | 562 |
|
... | ... |
@@ -644,6 +651,7 @@ const ( |
644 | 644 |
flagHealthInterval = "health-interval" |
645 | 645 |
flagHealthRetries = "health-retries" |
646 | 646 |
flagHealthTimeout = "health-timeout" |
647 |
+ flagHealthStartPeriod = "health-start-period" |
|
647 | 648 |
flagNoHealthcheck = "no-healthcheck" |
648 | 649 |
flagSecret = "secret" |
649 | 650 |
flagSecretAdd = "secret-add" |
... | ... |
@@ -71,18 +71,20 @@ func TestUint64OptSetAndValue(t *testing.T) { |
71 | 71 |
func TestHealthCheckOptionsToHealthConfig(t *testing.T) { |
72 | 72 |
dur := time.Second |
73 | 73 |
opt := healthCheckOptions{ |
74 |
- cmd: "curl", |
|
75 |
- interval: PositiveDurationOpt{DurationOpt{value: &dur}}, |
|
76 |
- timeout: PositiveDurationOpt{DurationOpt{value: &dur}}, |
|
77 |
- retries: 10, |
|
74 |
+ cmd: "curl", |
|
75 |
+ interval: PositiveDurationOpt{DurationOpt{value: &dur}}, |
|
76 |
+ timeout: PositiveDurationOpt{DurationOpt{value: &dur}}, |
|
77 |
+ startPeriod: PositiveDurationOpt{DurationOpt{value: &dur}}, |
|
78 |
+ retries: 10, |
|
78 | 79 |
} |
79 | 80 |
config, err := opt.toHealthConfig() |
80 | 81 |
assert.NilError(t, err) |
81 | 82 |
assert.Equal(t, reflect.DeepEqual(config, &container.HealthConfig{ |
82 |
- Test: []string{"CMD-SHELL", "curl"}, |
|
83 |
- Interval: time.Second, |
|
84 |
- Timeout: time.Second, |
|
85 |
- Retries: 10, |
|
83 |
+ Test: []string{"CMD-SHELL", "curl"}, |
|
84 |
+ Interval: time.Second, |
|
85 |
+ Timeout: time.Second, |
|
86 |
+ StartPeriod: time.Second, |
|
87 |
+ Retries: 10, |
|
86 | 88 |
}), true) |
87 | 89 |
} |
88 | 90 |
|
... | ... |
@@ -897,7 +897,7 @@ func updateLogDriver(flags *pflag.FlagSet, taskTemplate *swarm.TaskSpec) error { |
897 | 897 |
} |
898 | 898 |
|
899 | 899 |
func updateHealthcheck(flags *pflag.FlagSet, containerSpec *swarm.ContainerSpec) error { |
900 |
- if !anyChanged(flags, flagNoHealthcheck, flagHealthCmd, flagHealthInterval, flagHealthRetries, flagHealthTimeout) { |
|
900 |
+ if !anyChanged(flags, flagNoHealthcheck, flagHealthCmd, flagHealthInterval, flagHealthRetries, flagHealthTimeout, flagHealthStartPeriod) { |
|
901 | 901 |
return nil |
902 | 902 |
} |
903 | 903 |
if containerSpec.Healthcheck == nil { |
... | ... |
@@ -908,7 +908,7 @@ func updateHealthcheck(flags *pflag.FlagSet, containerSpec *swarm.ContainerSpec) |
908 | 908 |
return err |
909 | 909 |
} |
910 | 910 |
if noHealthcheck { |
911 |
- if !anyChanged(flags, flagHealthCmd, flagHealthInterval, flagHealthRetries, flagHealthTimeout) { |
|
911 |
+ if !anyChanged(flags, flagHealthCmd, flagHealthInterval, flagHealthRetries, flagHealthTimeout, flagHealthStartPeriod) { |
|
912 | 912 |
containerSpec.Healthcheck = &container.HealthConfig{ |
913 | 913 |
Test: []string{"NONE"}, |
914 | 914 |
} |
... | ... |
@@ -927,6 +927,10 @@ func updateHealthcheck(flags *pflag.FlagSet, containerSpec *swarm.ContainerSpec) |
927 | 927 |
val := *flags.Lookup(flagHealthTimeout).Value.(*PositiveDurationOpt).Value() |
928 | 928 |
containerSpec.Healthcheck.Timeout = val |
929 | 929 |
} |
930 |
+ if flags.Changed(flagHealthStartPeriod) { |
|
931 |
+ val := *flags.Lookup(flagHealthStartPeriod).Value.(*PositiveDurationOpt).Value() |
|
932 |
+ containerSpec.Healthcheck.StartPeriod = val |
|
933 |
+ } |
|
930 | 934 |
if flags.Changed(flagHealthRetries) { |
931 | 935 |
containerSpec.Healthcheck.Retries, _ = flags.GetInt(flagHealthRetries) |
932 | 936 |
} |
... | ... |
@@ -312,6 +312,11 @@ func TestUpdateHealthcheckTable(t *testing.T) { |
312 | 312 |
expected: &container.HealthConfig{Test: []string{"CMD", "cmd1"}}, |
313 | 313 |
}, |
314 | 314 |
{ |
315 |
+ flags: [][2]string{{"health-start-period", "1m"}}, |
|
316 |
+ initial: &container.HealthConfig{Test: []string{"CMD", "cmd1"}}, |
|
317 |
+ expected: &container.HealthConfig{Test: []string{"CMD", "cmd1"}, StartPeriod: time.Minute}, |
|
318 |
+ }, |
|
319 |
+ { |
|
315 | 320 |
flags: [][2]string{{"health-cmd", "cmd1"}, {"no-healthcheck", "true"}}, |
316 | 321 |
err: "--no-healthcheck conflicts with --health-* options", |
317 | 322 |
}, |
... | ... |
@@ -255,9 +255,9 @@ func convertHealthcheck(healthcheck *composetypes.HealthCheckConfig) (*container |
255 | 255 |
return nil, nil |
256 | 256 |
} |
257 | 257 |
var ( |
258 |
- err error |
|
259 |
- timeout, interval time.Duration |
|
260 |
- retries int |
|
258 |
+ err error |
|
259 |
+ timeout, interval, startPeriod time.Duration |
|
260 |
+ retries int |
|
261 | 261 |
) |
262 | 262 |
if healthcheck.Disable { |
263 | 263 |
if len(healthcheck.Test) != 0 { |
... | ... |
@@ -280,14 +280,21 @@ func convertHealthcheck(healthcheck *composetypes.HealthCheckConfig) (*container |
280 | 280 |
return nil, err |
281 | 281 |
} |
282 | 282 |
} |
283 |
+ if healthcheck.StartPeriod != "" { |
|
284 |
+ startPeriod, err = time.ParseDuration(healthcheck.StartPeriod) |
|
285 |
+ if err != nil { |
|
286 |
+ return nil, err |
|
287 |
+ } |
|
288 |
+ } |
|
283 | 289 |
if healthcheck.Retries != nil { |
284 | 290 |
retries = int(*healthcheck.Retries) |
285 | 291 |
} |
286 | 292 |
return &container.HealthConfig{ |
287 |
- Test: healthcheck.Test, |
|
288 |
- Timeout: timeout, |
|
289 |
- Interval: interval, |
|
290 |
- Retries: retries, |
|
293 |
+ Test: healthcheck.Test, |
|
294 |
+ Timeout: timeout, |
|
295 |
+ Interval: interval, |
|
296 |
+ Retries: retries, |
|
297 |
+ StartPeriod: startPeriod, |
|
291 | 298 |
}, nil |
292 | 299 |
} |
293 | 300 |
|
... | ... |
@@ -163,11 +163,12 @@ type DeployConfig struct { |
163 | 163 |
|
164 | 164 |
// HealthCheckConfig the healthcheck configuration for a service |
165 | 165 |
type HealthCheckConfig struct { |
166 |
- Test HealthCheckTest |
|
167 |
- Timeout string |
|
168 |
- Interval string |
|
169 |
- Retries *uint64 |
|
170 |
- Disable bool |
|
166 |
+ Test HealthCheckTest |
|
167 |
+ Timeout string |
|
168 |
+ Interval string |
|
169 |
+ Retries *uint64 |
|
170 |
+ StartPeriod string |
|
171 |
+ Disable bool |
|
171 | 172 |
} |
172 | 173 |
|
173 | 174 |
// HealthCheckTest is the command run to test the health of a service |
... | ... |
@@ -221,19 +221,22 @@ func containerToGRPC(c types.ContainerSpec) (*swarmapi.ContainerSpec, error) { |
221 | 221 |
func healthConfigFromGRPC(h *swarmapi.HealthConfig) *container.HealthConfig { |
222 | 222 |
interval, _ := gogotypes.DurationFromProto(h.Interval) |
223 | 223 |
timeout, _ := gogotypes.DurationFromProto(h.Timeout) |
224 |
+ startPeriod, _ := gogotypes.DurationFromProto(h.Timeout) |
|
224 | 225 |
return &container.HealthConfig{ |
225 |
- Test: h.Test, |
|
226 |
- Interval: interval, |
|
227 |
- Timeout: timeout, |
|
228 |
- Retries: int(h.Retries), |
|
226 |
+ Test: h.Test, |
|
227 |
+ Interval: interval, |
|
228 |
+ Timeout: timeout, |
|
229 |
+ Retries: int(h.Retries), |
|
230 |
+ StartPeriod: startPeriod, |
|
229 | 231 |
} |
230 | 232 |
} |
231 | 233 |
|
232 | 234 |
func healthConfigToGRPC(h *container.HealthConfig) *swarmapi.HealthConfig { |
233 | 235 |
return &swarmapi.HealthConfig{ |
234 |
- Test: h.Test, |
|
235 |
- Interval: gogotypes.DurationProto(h.Interval), |
|
236 |
- Timeout: gogotypes.DurationProto(h.Timeout), |
|
237 |
- Retries: int32(h.Retries), |
|
236 |
+ Test: h.Test, |
|
237 |
+ Interval: gogotypes.DurationProto(h.Interval), |
|
238 |
+ Timeout: gogotypes.DurationProto(h.Timeout), |
|
239 |
+ Retries: int32(h.Retries), |
|
240 |
+ StartPeriod: gogotypes.DurationProto(h.StartPeriod), |
|
238 | 241 |
} |
239 | 242 |
} |
... | ... |
@@ -326,11 +326,13 @@ func (c *containerConfig) healthcheck() *enginecontainer.HealthConfig { |
326 | 326 |
} |
327 | 327 |
interval, _ := gogotypes.DurationFromProto(hcSpec.Interval) |
328 | 328 |
timeout, _ := gogotypes.DurationFromProto(hcSpec.Timeout) |
329 |
+ startPeriod, _ := gogotypes.DurationFromProto(hcSpec.StartPeriod) |
|
329 | 330 |
return &enginecontainer.HealthConfig{ |
330 |
- Test: hcSpec.Test, |
|
331 |
- Interval: interval, |
|
332 |
- Timeout: timeout, |
|
333 |
- Retries: int(hcSpec.Retries), |
|
331 |
+ Test: hcSpec.Test, |
|
332 |
+ Interval: interval, |
|
333 |
+ Timeout: timeout, |
|
334 |
+ Retries: int(hcSpec.Retries), |
|
335 |
+ StartPeriod: startPeriod, |
|
334 | 336 |
} |
335 | 337 |
} |
336 | 338 |
|
... | ... |
@@ -94,6 +94,9 @@ func merge(userConf, imageConf *containertypes.Config) error { |
94 | 94 |
if userConf.Healthcheck.Timeout == 0 { |
95 | 95 |
userConf.Healthcheck.Timeout = imageConf.Healthcheck.Timeout |
96 | 96 |
} |
97 |
+ if userConf.Healthcheck.StartPeriod == 0 { |
|
98 |
+ userConf.Healthcheck.StartPeriod = imageConf.Healthcheck.StartPeriod |
|
99 |
+ } |
|
97 | 100 |
if userConf.Healthcheck.Retries == 0 { |
98 | 101 |
userConf.Healthcheck.Retries = imageConf.Healthcheck.Retries |
99 | 102 |
} |
... | ... |
@@ -255,6 +255,10 @@ func (daemon *Daemon) verifyContainerSettings(hostConfig *containertypes.HostCon |
255 | 255 |
if config.Healthcheck.Retries < 0 { |
256 | 256 |
return nil, fmt.Errorf("Retries in Healthcheck cannot be negative") |
257 | 257 |
} |
258 |
+ |
|
259 |
+ if config.Healthcheck.StartPeriod < 0 { |
|
260 |
+ return nil, fmt.Errorf("StartPeriod in Healthcheck cannot be negative") |
|
261 |
+ } |
|
258 | 262 |
} |
259 | 263 |
} |
260 | 264 |
|
... | ... |
@@ -30,6 +30,10 @@ const ( |
30 | 30 |
// than this, the check is considered to have failed. |
31 | 31 |
defaultProbeTimeout = 30 * time.Second |
32 | 32 |
|
33 |
+ // The time given for the container to start before the health check starts considering |
|
34 |
+ // the container unstable. Defaults to none. |
|
35 |
+ defaultStartPeriod = 0 * time.Second |
|
36 |
+ |
|
33 | 37 |
// Default number of consecutive failures of the health check |
34 | 38 |
// for the container to be considered unhealthy. |
35 | 39 |
defaultProbeRetries = 3 |
... | ... |
@@ -133,11 +137,28 @@ func handleProbeResult(d *Daemon, c *container.Container, result *types.Healthch |
133 | 133 |
if result.ExitCode == exitStatusHealthy { |
134 | 134 |
h.FailingStreak = 0 |
135 | 135 |
h.Status = types.Healthy |
136 |
- } else { |
|
137 |
- // Failure (including invalid exit code) |
|
138 |
- h.FailingStreak++ |
|
139 |
- if h.FailingStreak >= retries { |
|
140 |
- h.Status = types.Unhealthy |
|
136 |
+ } else { // Failure (including invalid exit code) |
|
137 |
+ shouldIncrementStreak := true |
|
138 |
+ |
|
139 |
+ // If the container is starting (i.e. we never had a successful health check) |
|
140 |
+ // then we check if we are within the start period of the container in which |
|
141 |
+ // case we do not increment the failure streak. |
|
142 |
+ if h.Status == types.Starting { |
|
143 |
+ startPeriod := timeoutWithDefault(c.Config.Healthcheck.StartPeriod, defaultStartPeriod) |
|
144 |
+ timeSinceStart := result.Start.Sub(c.State.StartedAt) |
|
145 |
+ |
|
146 |
+ // If still within the start period, then don't increment failing streak. |
|
147 |
+ if timeSinceStart < startPeriod { |
|
148 |
+ shouldIncrementStreak = false |
|
149 |
+ } |
|
150 |
+ } |
|
151 |
+ |
|
152 |
+ if shouldIncrementStreak { |
|
153 |
+ h.FailingStreak++ |
|
154 |
+ |
|
155 |
+ if h.FailingStreak >= retries { |
|
156 |
+ h.Status = types.Unhealthy |
|
157 |
+ } |
|
141 | 158 |
} |
142 | 159 |
// Else we're starting or healthy. Stay in that state. |
143 | 160 |
} |
... | ... |
@@ -116,4 +116,30 @@ func TestHealthStates(t *testing.T) { |
116 | 116 |
if c.State.Health.FailingStreak != 0 { |
117 | 117 |
t.Errorf("Expecting FailingStreak=0, but got %d\n", c.State.Health.FailingStreak) |
118 | 118 |
} |
119 |
+ |
|
120 |
+ // Test start period |
|
121 |
+ |
|
122 |
+ reset(c) |
|
123 |
+ c.Config.Healthcheck.Retries = 2 |
|
124 |
+ c.Config.Healthcheck.StartPeriod = 30 * time.Second |
|
125 |
+ |
|
126 |
+ handleResult(c.State.StartedAt.Add(20*time.Second), 1) |
|
127 |
+ if c.State.Health.Status != types.Starting { |
|
128 |
+ t.Errorf("Expecting starting, but got %#v\n", c.State.Health.Status) |
|
129 |
+ } |
|
130 |
+ if c.State.Health.FailingStreak != 0 { |
|
131 |
+ t.Errorf("Expecting FailingStreak=0, but got %d\n", c.State.Health.FailingStreak) |
|
132 |
+ } |
|
133 |
+ handleResult(c.State.StartedAt.Add(50*time.Second), 1) |
|
134 |
+ if c.State.Health.Status != types.Starting { |
|
135 |
+ t.Errorf("Expecting starting, but got %#v\n", c.State.Health.Status) |
|
136 |
+ } |
|
137 |
+ if c.State.Health.FailingStreak != 1 { |
|
138 |
+ t.Errorf("Expecting FailingStreak=1, but got %d\n", c.State.Health.FailingStreak) |
|
139 |
+ } |
|
140 |
+ handleResult(c.State.StartedAt.Add(80*time.Second), 0) |
|
141 |
+ expect("health_status: healthy") |
|
142 |
+ if c.State.Health.FailingStreak != 0 { |
|
143 |
+ t.Errorf("Expecting FailingStreak=0, but got %d\n", c.State.Health.FailingStreak) |
|
144 |
+ } |
|
119 | 145 |
} |
... | ... |
@@ -22,6 +22,7 @@ keywords: "API, Docker, rcli, REST, documentation" |
22 | 22 |
* `POST /networks/create` now supports creating the ingress network, by specifying an `Ingress` boolean field. As of now this is supported only when using the overlay network driver. |
23 | 23 |
* `GET /networks/(name)` now returns an `Ingress` field showing whether the network is the ingress one. |
24 | 24 |
* `GET /networks/` now supports a `scope` filter to filter networks based on the network mode (`swarm`, `global`, or `local`). |
25 |
+* `POST /containers/create`, `POST /service/create` and `POST /services/(id or name)/update` now takes the field `StartPeriod` as a part of the `HealthConfig` allowing for specification of a period during which the container should not be considered unealthy even if health checks do not pass. |
|
25 | 26 |
|
26 | 27 |
## v1.28 API changes |
27 | 28 |
|
... | ... |
@@ -1591,6 +1591,7 @@ The options that can appear before `CMD` are: |
1591 | 1591 |
|
1592 | 1592 |
* `--interval=DURATION` (default: `30s`) |
1593 | 1593 |
* `--timeout=DURATION` (default: `30s`) |
1594 |
+* `--start-period=DURATION` (default: `0s`) |
|
1594 | 1595 |
* `--retries=N` (default: `3`) |
1595 | 1596 |
|
1596 | 1597 |
The health check will first run **interval** seconds after the container is |
... | ... |
@@ -1602,6 +1603,11 @@ is considered to have failed. |
1602 | 1602 |
It takes **retries** consecutive failures of the health check for the container |
1603 | 1603 |
to be considered `unhealthy`. |
1604 | 1604 |
|
1605 |
+**start period** provides initialization time for containers that need time to bootstrap. |
|
1606 |
+Probe failure during that period will not be counted towards the maximum number of retries. |
|
1607 |
+However, if a health check succeeds during the start period, the container is considered |
|
1608 |
+started and all consecutive failures will be counted towards the maximum number of retries. |
|
1609 |
+ |
|
1605 | 1610 |
There can only be one `HEALTHCHECK` instruction in a Dockerfile. If you list |
1606 | 1611 |
more than one then only the last `HEALTHCHECK` will take effect. |
1607 | 1612 |
|
... | ... |
@@ -23,117 +23,118 @@ Usage: docker create [OPTIONS] IMAGE [COMMAND] [ARG...] |
23 | 23 |
Create a new container |
24 | 24 |
|
25 | 25 |
Options: |
26 |
- --add-host value Add a custom host-to-IP mapping (host:ip) (default []) |
|
27 |
- -a, --attach value Attach to STDIN, STDOUT or STDERR (default []) |
|
28 |
- --blkio-weight value Block IO (relative weight), between 10 and 1000 |
|
29 |
- --blkio-weight-device value Block IO weight (relative device weight) (default []) |
|
30 |
- --cap-add value Add Linux capabilities (default []) |
|
31 |
- --cap-drop value Drop Linux capabilities (default []) |
|
32 |
- --cgroup-parent string Optional parent cgroup for the container |
|
33 |
- --cidfile string Write the container ID to the file |
|
34 |
- --cpu-count int The number of CPUs available for execution by the container. |
|
35 |
- Windows daemon only. On Windows Server containers, this is |
|
36 |
- approximated as a percentage of total CPU usage. |
|
37 |
- --cpu-percent int CPU percent (Windows only) |
|
38 |
- --cpu-period int Limit CPU CFS (Completely Fair Scheduler) period |
|
39 |
- --cpu-quota int Limit CPU CFS (Completely Fair Scheduler) quota |
|
40 |
- -c, --cpu-shares int CPU shares (relative weight) |
|
41 |
- --cpus NanoCPUs Number of CPUs (default 0.000) |
|
42 |
- --cpu-rt-period int Limit the CPU real-time period in microseconds |
|
43 |
- --cpu-rt-runtime int Limit the CPU real-time runtime in microseconds |
|
44 |
- --cpuset-cpus string CPUs in which to allow execution (0-3, 0,1) |
|
45 |
- --cpuset-mems string MEMs in which to allow execution (0-3, 0,1) |
|
46 |
- --device value Add a host device to the container (default []) |
|
47 |
- --device-cgroup-rule value Add a rule to the cgroup allowed devices list |
|
48 |
- --device-read-bps value Limit read rate (bytes per second) from a device (default []) |
|
49 |
- --device-read-iops value Limit read rate (IO per second) from a device (default []) |
|
50 |
- --device-write-bps value Limit write rate (bytes per second) to a device (default []) |
|
51 |
- --device-write-iops value Limit write rate (IO per second) to a device (default []) |
|
52 |
- --disable-content-trust Skip image verification (default true) |
|
53 |
- --dns value Set custom DNS servers (default []) |
|
54 |
- --dns-option value Set DNS options (default []) |
|
55 |
- --dns-search value Set custom DNS search domains (default []) |
|
56 |
- --entrypoint string Overwrite the default ENTRYPOINT of the image |
|
57 |
- -e, --env value Set environment variables (default []) |
|
58 |
- --env-file value Read in a file of environment variables (default []) |
|
59 |
- --expose value Expose a port or a range of ports (default []) |
|
60 |
- --group-add value Add additional groups to join (default []) |
|
61 |
- --health-cmd string Command to run to check health |
|
62 |
- --health-interval duration Time between running the check (ns|us|ms|s|m|h) (default 0s) |
|
63 |
- --health-retries int Consecutive failures needed to report unhealthy |
|
64 |
- --health-timeout duration Maximum time to allow one check to run (ns|us|ms|s|m|h) (default 0s) |
|
65 |
- --help Print usage |
|
66 |
- -h, --hostname string Container host name |
|
67 |
- --init Run an init inside the container that forwards signals and reaps processes |
|
68 |
- --init-path string Path to the docker-init binary |
|
69 |
- -i, --interactive Keep STDIN open even if not attached |
|
70 |
- --io-maxbandwidth string Maximum IO bandwidth limit for the system drive (Windows only) |
|
71 |
- --io-maxiops uint Maximum IOps limit for the system drive (Windows only) |
|
72 |
- --ip string IPv4 address (e.g., 172.30.100.104) |
|
73 |
- --ip6 string IPv6 address (e.g., 2001:db8::33) |
|
74 |
- --ipc string IPC namespace to use |
|
75 |
- --isolation string Container isolation technology |
|
76 |
- --kernel-memory string Kernel memory limit |
|
77 |
- -l, --label value Set meta data on a container (default []) |
|
78 |
- --label-file value Read in a line delimited file of labels (default []) |
|
79 |
- --link value Add link to another container (default []) |
|
80 |
- --link-local-ip value Container IPv4/IPv6 link-local addresses (default []) |
|
81 |
- --log-driver string Logging driver for the container |
|
82 |
- --log-opt value Log driver options (default []) |
|
83 |
- --mac-address string Container MAC address (e.g., 92:d0:c6:0a:29:33) |
|
84 |
- -m, --memory string Memory limit |
|
85 |
- --memory-reservation string Memory soft limit |
|
86 |
- --memory-swap string Swap limit equal to memory plus swap: '-1' to enable unlimited swap |
|
87 |
- --memory-swappiness int Tune container memory swappiness (0 to 100) (default -1) |
|
88 |
- --mount value Attach a filesytem mount to the container (default []) |
|
89 |
- --name string Assign a name to the container |
|
90 |
- --network-alias value Add network-scoped alias for the container (default []) |
|
91 |
- --network string Connect a container to a network (default "default") |
|
92 |
- 'bridge': create a network stack on the default Docker bridge |
|
93 |
- 'none': no networking |
|
94 |
- 'container:<name|id>': reuse another container's network stack |
|
95 |
- 'host': use the Docker host network stack |
|
96 |
- '<network-name>|<network-id>': connect to a user-defined network |
|
97 |
- --no-healthcheck Disable any container-specified HEALTHCHECK |
|
98 |
- --oom-kill-disable Disable OOM Killer |
|
99 |
- --oom-score-adj int Tune host's OOM preferences (-1000 to 1000) |
|
100 |
- --pid string PID namespace to use |
|
101 |
- --pids-limit int Tune container pids limit (set -1 for unlimited), kernel >= 4.3 |
|
102 |
- --privileged Give extended privileges to this container |
|
103 |
- -p, --publish value Publish a container's port(s) to the host (default []) |
|
104 |
- -P, --publish-all Publish all exposed ports to random ports |
|
105 |
- --read-only Mount the container's root filesystem as read only |
|
106 |
- --restart string Restart policy to apply when a container exits (default "no") |
|
107 |
- Possible values are: no, on-failure[:max-retry], always, unless-stopped |
|
108 |
- --rm Automatically remove the container when it exits |
|
109 |
- --runtime string Runtime to use for this container |
|
110 |
- --security-opt value Security Options (default []) |
|
111 |
- --shm-size bytes Size of /dev/shm |
|
112 |
- The format is `<number><unit>`. `number` must be greater than `0`. |
|
113 |
- Unit is optional and can be `b` (bytes), `k` (kilobytes), `m` (megabytes), |
|
114 |
- or `g` (gigabytes). If you omit the unit, the system uses bytes. |
|
115 |
- --stop-signal string Signal to stop a container (default "SIGTERM") |
|
116 |
- --stop-timeout=10 Timeout (in seconds) to stop a container |
|
117 |
- --storage-opt value Storage driver options for the container (default []) |
|
118 |
- --sysctl value Sysctl options (default map[]) |
|
119 |
- --tmpfs value Mount a tmpfs directory (default []) |
|
120 |
- -t, --tty Allocate a pseudo-TTY |
|
121 |
- --ulimit value Ulimit options (default []) |
|
122 |
- -u, --user string Username or UID (format: <name|uid>[:<group|gid>]) |
|
123 |
- --userns string User namespace to use |
|
124 |
- 'host': Use the Docker host user namespace |
|
125 |
- '': Use the Docker daemon user namespace specified by `--userns-remap` option. |
|
126 |
- --uts string UTS namespace to use |
|
127 |
- -v, --volume value Bind mount a volume (default []). The format |
|
128 |
- is `[host-src:]container-dest[:<options>]`. |
|
129 |
- The comma-delimited `options` are [rw|ro], |
|
130 |
- [z|Z], [[r]shared|[r]slave|[r]private], |
|
131 |
- [delegated|cached|consistent], and |
|
132 |
- [nocopy]. The 'host-src' is an absolute path |
|
133 |
- or a name value. |
|
134 |
- --volume-driver string Optional volume driver for the container |
|
135 |
- --volumes-from value Mount volumes from the specified container(s) (default []) |
|
136 |
- -w, --workdir string Working directory inside the container |
|
26 |
+ --add-host value Add a custom host-to-IP mapping (host:ip) (default []) |
|
27 |
+ -a, --attach value Attach to STDIN, STDOUT or STDERR (default []) |
|
28 |
+ --blkio-weight value Block IO (relative weight), between 10 and 1000 |
|
29 |
+ --blkio-weight-device value Block IO weight (relative device weight) (default []) |
|
30 |
+ --cap-add value Add Linux capabilities (default []) |
|
31 |
+ --cap-drop value Drop Linux capabilities (default []) |
|
32 |
+ --cgroup-parent string Optional parent cgroup for the container |
|
33 |
+ --cidfile string Write the container ID to the file |
|
34 |
+ --cpu-count int The number of CPUs available for execution by the container. |
|
35 |
+ Windows daemon only. On Windows Server containers, this is |
|
36 |
+ approximated as a percentage of total CPU usage. |
|
37 |
+ --cpu-percent int CPU percent (Windows only) |
|
38 |
+ --cpu-period int Limit CPU CFS (Completely Fair Scheduler) period |
|
39 |
+ --cpu-quota int Limit CPU CFS (Completely Fair Scheduler) quota |
|
40 |
+ -c, --cpu-shares int CPU shares (relative weight) |
|
41 |
+ --cpus NanoCPUs Number of CPUs (default 0.000) |
|
42 |
+ --cpu-rt-period int Limit the CPU real-time period in microseconds |
|
43 |
+ --cpu-rt-runtime int Limit the CPU real-time runtime in microseconds |
|
44 |
+ --cpuset-cpus string CPUs in which to allow execution (0-3, 0,1) |
|
45 |
+ --cpuset-mems string MEMs in which to allow execution (0-3, 0,1) |
|
46 |
+ --device value Add a host device to the container (default []) |
|
47 |
+ --device-cgroup-rule value Add a rule to the cgroup allowed devices list |
|
48 |
+ --device-read-bps value Limit read rate (bytes per second) from a device (default []) |
|
49 |
+ --device-read-iops value Limit read rate (IO per second) from a device (default []) |
|
50 |
+ --device-write-bps value Limit write rate (bytes per second) to a device (default []) |
|
51 |
+ --device-write-iops value Limit write rate (IO per second) to a device (default []) |
|
52 |
+ --disable-content-trust Skip image verification (default true) |
|
53 |
+ --dns value Set custom DNS servers (default []) |
|
54 |
+ --dns-option value Set DNS options (default []) |
|
55 |
+ --dns-search value Set custom DNS search domains (default []) |
|
56 |
+ --entrypoint string Overwrite the default ENTRYPOINT of the image |
|
57 |
+ -e, --env value Set environment variables (default []) |
|
58 |
+ --env-file value Read in a file of environment variables (default []) |
|
59 |
+ --expose value Expose a port or a range of ports (default []) |
|
60 |
+ --group-add value Add additional groups to join (default []) |
|
61 |
+ --health-cmd string Command to run to check health |
|
62 |
+ --health-interval duration Time between running the check (ns|us|ms|s|m|h) (default 0s) |
|
63 |
+ --health-retries int Consecutive failures needed to report unhealthy |
|
64 |
+ --health-timeout duration Maximum time to allow one check to run (ns|us|ms|s|m|h) (default 0s) |
|
65 |
+ --health-start-period duration Start period for the container to initialize before counting retries towards unstable (ns|us|ms|s|m|h) (default 0s) |
|
66 |
+ --help Print usage |
|
67 |
+ -h, --hostname string Container host name |
|
68 |
+ --init Run an init inside the container that forwards signals and reaps processes |
|
69 |
+ --init-path string Path to the docker-init binary |
|
70 |
+ -i, --interactive Keep STDIN open even if not attached |
|
71 |
+ --io-maxbandwidth string Maximum IO bandwidth limit for the system drive (Windows only) |
|
72 |
+ --io-maxiops uint Maximum IOps limit for the system drive (Windows only) |
|
73 |
+ --ip string IPv4 address (e.g., 172.30.100.104) |
|
74 |
+ --ip6 string IPv6 address (e.g., 2001:db8::33) |
|
75 |
+ --ipc string IPC namespace to use |
|
76 |
+ --isolation string Container isolation technology |
|
77 |
+ --kernel-memory string Kernel memory limit |
|
78 |
+ -l, --label value Set meta data on a container (default []) |
|
79 |
+ --label-file value Read in a line delimited file of labels (default []) |
|
80 |
+ --link value Add link to another container (default []) |
|
81 |
+ --link-local-ip value Container IPv4/IPv6 link-local addresses (default []) |
|
82 |
+ --log-driver string Logging driver for the container |
|
83 |
+ --log-opt value Log driver options (default []) |
|
84 |
+ --mac-address string Container MAC address (e.g., 92:d0:c6:0a:29:33) |
|
85 |
+ -m, --memory string Memory limit |
|
86 |
+ --memory-reservation string Memory soft limit |
|
87 |
+ --memory-swap string Swap limit equal to memory plus swap: '-1' to enable unlimited swap |
|
88 |
+ --memory-swappiness int Tune container memory swappiness (0 to 100) (default -1) |
|
89 |
+ --mount value Attach a filesytem mount to the container (default []) |
|
90 |
+ --name string Assign a name to the container |
|
91 |
+ --network-alias value Add network-scoped alias for the container (default []) |
|
92 |
+ --network string Connect a container to a network (default "default") |
|
93 |
+ 'bridge': create a network stack on the default Docker bridge |
|
94 |
+ 'none': no networking |
|
95 |
+ 'container:<name|id>': reuse another container's network stack |
|
96 |
+ 'host': use the Docker host network stack |
|
97 |
+ '<network-name>|<network-id>': connect to a user-defined network |
|
98 |
+ --no-healthcheck Disable any container-specified HEALTHCHECK |
|
99 |
+ --oom-kill-disable Disable OOM Killer |
|
100 |
+ --oom-score-adj int Tune host's OOM preferences (-1000 to 1000) |
|
101 |
+ --pid string PID namespace to use |
|
102 |
+ --pids-limit int Tune container pids limit (set -1 for unlimited), kernel >= 4.3 |
|
103 |
+ --privileged Give extended privileges to this container |
|
104 |
+ -p, --publish value Publish a container's port(s) to the host (default []) |
|
105 |
+ -P, --publish-all Publish all exposed ports to random ports |
|
106 |
+ --read-only Mount the container's root filesystem as read only |
|
107 |
+ --restart string Restart policy to apply when a container exits (default "no") |
|
108 |
+ Possible values are: no, on-failure[:max-retry], always, unless-stopped |
|
109 |
+ --rm Automatically remove the container when it exits |
|
110 |
+ --runtime string Runtime to use for this container |
|
111 |
+ --security-opt value Security Options (default []) |
|
112 |
+ --shm-size bytes Size of /dev/shm |
|
113 |
+ The format is `<number><unit>`. `number` must be greater than `0`. |
|
114 |
+ Unit is optional and can be `b` (bytes), `k` (kilobytes), `m` (megabytes), |
|
115 |
+ or `g` (gigabytes). If you omit the unit, the system uses bytes. |
|
116 |
+ --stop-signal string Signal to stop a container (default "SIGTERM") |
|
117 |
+ --stop-timeout=10 Timeout (in seconds) to stop a container |
|
118 |
+ --storage-opt value Storage driver options for the container (default []) |
|
119 |
+ --sysctl value Sysctl options (default map[]) |
|
120 |
+ --tmpfs value Mount a tmpfs directory (default []) |
|
121 |
+ -t, --tty Allocate a pseudo-TTY |
|
122 |
+ --ulimit value Ulimit options (default []) |
|
123 |
+ -u, --user string Username or UID (format: <name|uid>[:<group|gid>]) |
|
124 |
+ --userns string User namespace to use |
|
125 |
+ 'host': Use the Docker host user namespace |
|
126 |
+ '': Use the Docker daemon user namespace specified by `--userns-remap` option. |
|
127 |
+ --uts string UTS namespace to use |
|
128 |
+ -v, --volume value Bind mount a volume (default []). The format |
|
129 |
+ is `[host-src:]container-dest[:<options>]`. |
|
130 |
+ The comma-delimited `options` are [rw|ro], |
|
131 |
+ [z|Z], [[r]shared|[r]slave|[r]private], |
|
132 |
+ [delegated|cached|consistent], and |
|
133 |
+ [nocopy]. The 'host-src' is an absolute path |
|
134 |
+ or a name value. |
|
135 |
+ --volume-driver string Optional volume driver for the container |
|
136 |
+ --volumes-from value Mount volumes from the specified container(s) (default []) |
|
137 |
+ -w, --workdir string Working directory inside the container |
|
137 | 138 |
``` |
138 | 139 |
## Description |
139 | 140 |
|
... | ... |
@@ -21,130 +21,131 @@ Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...] |
21 | 21 |
Run a command in a new container |
22 | 22 |
|
23 | 23 |
Options: |
24 |
- --add-host value Add a custom host-to-IP mapping (host:ip) (default []) |
|
25 |
- -a, --attach value Attach to STDIN, STDOUT or STDERR (default []) |
|
26 |
- --blkio-weight value Block IO (relative weight), between 10 and 1000 |
|
27 |
- --blkio-weight-device value Block IO weight (relative device weight) (default []) |
|
28 |
- --cap-add value Add Linux capabilities (default []) |
|
29 |
- --cap-drop value Drop Linux capabilities (default []) |
|
30 |
- --cgroup-parent string Optional parent cgroup for the container |
|
31 |
- --cidfile string Write the container ID to the file |
|
32 |
- --cpu-count int The number of CPUs available for execution by the container. |
|
33 |
- Windows daemon only. On Windows Server containers, this is |
|
34 |
- approximated as a percentage of total CPU usage. |
|
35 |
- --cpu-percent int Limit percentage of CPU available for execution |
|
36 |
- by the container. Windows daemon only. |
|
37 |
- The processor resource controls are mutually |
|
38 |
- exclusive, the order of precedence is CPUCount |
|
39 |
- first, then CPUShares, and CPUPercent last. |
|
40 |
- --cpu-period int Limit CPU CFS (Completely Fair Scheduler) period |
|
41 |
- --cpu-quota int Limit CPU CFS (Completely Fair Scheduler) quota |
|
42 |
- -c, --cpu-shares int CPU shares (relative weight) |
|
43 |
- --cpus NanoCPUs Number of CPUs (default 0.000) |
|
44 |
- --cpu-rt-period int Limit the CPU real-time period in microseconds |
|
45 |
- --cpu-rt-runtime int Limit the CPU real-time runtime in microseconds |
|
46 |
- --cpuset-cpus string CPUs in which to allow execution (0-3, 0,1) |
|
47 |
- --cpuset-mems string MEMs in which to allow execution (0-3, 0,1) |
|
48 |
- -d, --detach Run container in background and print container ID |
|
49 |
- --detach-keys string Override the key sequence for detaching a container |
|
50 |
- --device value Add a host device to the container (default []) |
|
51 |
- --device-cgroup-rule value Add a rule to the cgroup allowed devices list |
|
52 |
- --device-read-bps value Limit read rate (bytes per second) from a device (default []) |
|
53 |
- --device-read-iops value Limit read rate (IO per second) from a device (default []) |
|
54 |
- --device-write-bps value Limit write rate (bytes per second) to a device (default []) |
|
55 |
- --device-write-iops value Limit write rate (IO per second) to a device (default []) |
|
56 |
- --disable-content-trust Skip image verification (default true) |
|
57 |
- --dns value Set custom DNS servers (default []) |
|
58 |
- --dns-option value Set DNS options (default []) |
|
59 |
- --dns-search value Set custom DNS search domains (default []) |
|
60 |
- --entrypoint string Overwrite the default ENTRYPOINT of the image |
|
61 |
- -e, --env value Set environment variables (default []) |
|
62 |
- --env-file value Read in a file of environment variables (default []) |
|
63 |
- --expose value Expose a port or a range of ports (default []) |
|
64 |
- --group-add value Add additional groups to join (default []) |
|
65 |
- --health-cmd string Command to run to check health |
|
66 |
- --health-interval duration Time between running the check (ns|us|ms|s|m|h) (default 0s) |
|
67 |
- --health-retries int Consecutive failures needed to report unhealthy |
|
68 |
- --health-timeout duration Maximum time to allow one check to run (ns|us|ms|s|m|h) (default 0s) |
|
69 |
- --help Print usage |
|
70 |
- -h, --hostname string Container host name |
|
71 |
- --init Run an init inside the container that forwards signals and reaps processes |
|
72 |
- --init-path string Path to the docker-init binary |
|
73 |
- -i, --interactive Keep STDIN open even if not attached |
|
74 |
- --io-maxbandwidth string Maximum IO bandwidth limit for the system drive (Windows only) |
|
75 |
- (Windows only). The format is `<number><unit>`. |
|
76 |
- Unit is optional and can be `b` (bytes per second), |
|
77 |
- `k` (kilobytes per second), `m` (megabytes per second), |
|
78 |
- or `g` (gigabytes per second). If you omit the unit, |
|
79 |
- the system uses bytes per second. |
|
80 |
- --io-maxbandwidth and --io-maxiops are mutually exclusive options. |
|
81 |
- --io-maxiops uint Maximum IOps limit for the system drive (Windows only) |
|
82 |
- --ip string IPv4 address (e.g., 172.30.100.104) |
|
83 |
- --ip6 string IPv6 address (e.g., 2001:db8::33) |
|
84 |
- --ipc string IPC namespace to use |
|
85 |
- --isolation string Container isolation technology |
|
86 |
- --kernel-memory string Kernel memory limit |
|
87 |
- -l, --label value Set meta data on a container (default []) |
|
88 |
- --label-file value Read in a line delimited file of labels (default []) |
|
89 |
- --link value Add link to another container (default []) |
|
90 |
- --link-local-ip value Container IPv4/IPv6 link-local addresses (default []) |
|
91 |
- --log-driver string Logging driver for the container |
|
92 |
- --log-opt value Log driver options (default []) |
|
93 |
- --mac-address string Container MAC address (e.g., 92:d0:c6:0a:29:33) |
|
94 |
- -m, --memory string Memory limit |
|
95 |
- --memory-reservation string Memory soft limit |
|
96 |
- --memory-swap string Swap limit equal to memory plus swap: '-1' to enable unlimited swap |
|
97 |
- --memory-swappiness int Tune container memory swappiness (0 to 100) (default -1) |
|
98 |
- --mount value Attach a filesystem mount to the container (default []) |
|
99 |
- --name string Assign a name to the container |
|
100 |
- --network-alias value Add network-scoped alias for the container (default []) |
|
101 |
- --network string Connect a container to a network |
|
102 |
- 'bridge': create a network stack on the default Docker bridge |
|
103 |
- 'none': no networking |
|
104 |
- 'container:<name|id>': reuse another container's network stack |
|
105 |
- 'host': use the Docker host network stack |
|
106 |
- '<network-name>|<network-id>': connect to a user-defined network |
|
107 |
- --no-healthcheck Disable any container-specified HEALTHCHECK |
|
108 |
- --oom-kill-disable Disable OOM Killer |
|
109 |
- --oom-score-adj int Tune host's OOM preferences (-1000 to 1000) |
|
110 |
- --pid string PID namespace to use |
|
111 |
- --pids-limit int Tune container pids limit (set -1 for unlimited) |
|
112 |
- --privileged Give extended privileges to this container |
|
113 |
- -p, --publish value Publish a container's port(s) to the host (default []) |
|
114 |
- -P, --publish-all Publish all exposed ports to random ports |
|
115 |
- --read-only Mount the container's root filesystem as read only |
|
116 |
- --restart string Restart policy to apply when a container exits (default "no") |
|
117 |
- Possible values are : no, on-failure[:max-retry], always, unless-stopped |
|
118 |
- --rm Automatically remove the container when it exits |
|
119 |
- --runtime string Runtime to use for this container |
|
120 |
- --security-opt value Security Options (default []) |
|
121 |
- --shm-size bytes Size of /dev/shm |
|
122 |
- The format is `<number><unit>`. `number` must be greater than `0`. |
|
123 |
- Unit is optional and can be `b` (bytes), `k` (kilobytes), `m` (megabytes), |
|
124 |
- or `g` (gigabytes). If you omit the unit, the system uses bytes. |
|
125 |
- --sig-proxy Proxy received signals to the process (default true) |
|
126 |
- --stop-signal string Signal to stop a container (default "SIGTERM") |
|
127 |
- --stop-timeout=10 Timeout (in seconds) to stop a container |
|
128 |
- --storage-opt value Storage driver options for the container (default []) |
|
129 |
- --sysctl value Sysctl options (default map[]) |
|
130 |
- --tmpfs value Mount a tmpfs directory (default []) |
|
131 |
- -t, --tty Allocate a pseudo-TTY |
|
132 |
- --ulimit value Ulimit options (default []) |
|
133 |
- -u, --user string Username or UID (format: <name|uid>[:<group|gid>]) |
|
134 |
- --userns string User namespace to use |
|
135 |
- 'host': Use the Docker host user namespace |
|
136 |
- '': Use the Docker daemon user namespace specified by `--userns-remap` option. |
|
137 |
- --uts string UTS namespace to use |
|
138 |
- -v, --volume value Bind mount a volume (default []). The format |
|
139 |
- is `[host-src:]container-dest[:<options>]`. |
|
140 |
- The comma-delimited `options` are [rw|ro], |
|
141 |
- [z|Z], [[r]shared|[r]slave|[r]private], |
|
142 |
- [delegated|cached|consistent], and |
|
143 |
- [nocopy]. The 'host-src' is an absolute path |
|
144 |
- or a name value. |
|
145 |
- --volume-driver string Optional volume driver for the container |
|
146 |
- --volumes-from value Mount volumes from the specified container(s) (default []) |
|
147 |
- -w, --workdir string Working directory inside the container |
|
24 |
+ --add-host value Add a custom host-to-IP mapping (host:ip) (default []) |
|
25 |
+ -a, --attach value Attach to STDIN, STDOUT or STDERR (default []) |
|
26 |
+ --blkio-weight value Block IO (relative weight), between 10 and 1000 |
|
27 |
+ --blkio-weight-device value Block IO weight (relative device weight) (default []) |
|
28 |
+ --cap-add value Add Linux capabilities (default []) |
|
29 |
+ --cap-drop value Drop Linux capabilities (default []) |
|
30 |
+ --cgroup-parent string Optional parent cgroup for the container |
|
31 |
+ --cidfile string Write the container ID to the file |
|
32 |
+ --cpu-count int The number of CPUs available for execution by the container. |
|
33 |
+ Windows daemon only. On Windows Server containers, this is |
|
34 |
+ approximated as a percentage of total CPU usage. |
|
35 |
+ --cpu-percent int Limit percentage of CPU available for execution |
|
36 |
+ by the container. Windows daemon only. |
|
37 |
+ The processor resource controls are mutually |
|
38 |
+ exclusive, the order of precedence is CPUCount |
|
39 |
+ first, then CPUShares, and CPUPercent last. |
|
40 |
+ --cpu-period int Limit CPU CFS (Completely Fair Scheduler) period |
|
41 |
+ --cpu-quota int Limit CPU CFS (Completely Fair Scheduler) quota |
|
42 |
+ -c, --cpu-shares int CPU shares (relative weight) |
|
43 |
+ --cpus NanoCPUs Number of CPUs (default 0.000) |
|
44 |
+ --cpu-rt-period int Limit the CPU real-time period in microseconds |
|
45 |
+ --cpu-rt-runtime int Limit the CPU real-time runtime in microseconds |
|
46 |
+ --cpuset-cpus string CPUs in which to allow execution (0-3, 0,1) |
|
47 |
+ --cpuset-mems string MEMs in which to allow execution (0-3, 0,1) |
|
48 |
+ -d, --detach Run container in background and print container ID |
|
49 |
+ --detach-keys string Override the key sequence for detaching a container |
|
50 |
+ --device value Add a host device to the container (default []) |
|
51 |
+ --device-cgroup-rule value Add a rule to the cgroup allowed devices list |
|
52 |
+ --device-read-bps value Limit read rate (bytes per second) from a device (default []) |
|
53 |
+ --device-read-iops value Limit read rate (IO per second) from a device (default []) |
|
54 |
+ --device-write-bps value Limit write rate (bytes per second) to a device (default []) |
|
55 |
+ --device-write-iops value Limit write rate (IO per second) to a device (default []) |
|
56 |
+ --disable-content-trust Skip image verification (default true) |
|
57 |
+ --dns value Set custom DNS servers (default []) |
|
58 |
+ --dns-option value Set DNS options (default []) |
|
59 |
+ --dns-search value Set custom DNS search domains (default []) |
|
60 |
+ --entrypoint string Overwrite the default ENTRYPOINT of the image |
|
61 |
+ -e, --env value Set environment variables (default []) |
|
62 |
+ --env-file value Read in a file of environment variables (default []) |
|
63 |
+ --expose value Expose a port or a range of ports (default []) |
|
64 |
+ --group-add value Add additional groups to join (default []) |
|
65 |
+ --health-cmd string Command to run to check health |
|
66 |
+ --health-interval duration Time between running the check (ns|us|ms|s|m|h) (default 0s) |
|
67 |
+ --health-retries int Consecutive failures needed to report unhealthy |
|
68 |
+ --health-timeout duration Maximum time to allow one check to run (ns|us|ms|s|m|h) (default 0s) |
|
69 |
+ --health-start-period duration Start period for the container to initialize before counting retries towards unstable (ns|us|ms|s|m|h) (default 0s) |
|
70 |
+ --help Print usage |
|
71 |
+ -h, --hostname string Container host name |
|
72 |
+ --init Run an init inside the container that forwards signals and reaps processes |
|
73 |
+ --init-path string Path to the docker-init binary |
|
74 |
+ -i, --interactive Keep STDIN open even if not attached |
|
75 |
+ --io-maxbandwidth string Maximum IO bandwidth limit for the system drive (Windows only) |
|
76 |
+ (Windows only). The format is `<number><unit>`. |
|
77 |
+ Unit is optional and can be `b` (bytes per second), |
|
78 |
+ `k` (kilobytes per second), `m` (megabytes per second), |
|
79 |
+ or `g` (gigabytes per second). If you omit the unit, |
|
80 |
+ the system uses bytes per second. |
|
81 |
+ --io-maxbandwidth and --io-maxiops are mutually exclusive options. |
|
82 |
+ --io-maxiops uint Maximum IOps limit for the system drive (Windows only) |
|
83 |
+ --ip string IPv4 address (e.g., 172.30.100.104) |
|
84 |
+ --ip6 string IPv6 address (e.g., 2001:db8::33) |
|
85 |
+ --ipc string IPC namespace to use |
|
86 |
+ --isolation string Container isolation technology |
|
87 |
+ --kernel-memory string Kernel memory limit |
|
88 |
+ -l, --label value Set meta data on a container (default []) |
|
89 |
+ --label-file value Read in a line delimited file of labels (default []) |
|
90 |
+ --link value Add link to another container (default []) |
|
91 |
+ --link-local-ip value Container IPv4/IPv6 link-local addresses (default []) |
|
92 |
+ --log-driver string Logging driver for the container |
|
93 |
+ --log-opt value Log driver options (default []) |
|
94 |
+ --mac-address string Container MAC address (e.g., 92:d0:c6:0a:29:33) |
|
95 |
+ -m, --memory string Memory limit |
|
96 |
+ --memory-reservation string Memory soft limit |
|
97 |
+ --memory-swap string Swap limit equal to memory plus swap: '-1' to enable unlimited swap |
|
98 |
+ --memory-swappiness int Tune container memory swappiness (0 to 100) (default -1) |
|
99 |
+ --mount value Attach a filesystem mount to the container (default []) |
|
100 |
+ --name string Assign a name to the container |
|
101 |
+ --network-alias value Add network-scoped alias for the container (default []) |
|
102 |
+ --network string Connect a container to a network |
|
103 |
+ 'bridge': create a network stack on the default Docker bridge |
|
104 |
+ 'none': no networking |
|
105 |
+ 'container:<name|id>': reuse another container's network stack |
|
106 |
+ 'host': use the Docker host network stack |
|
107 |
+ '<network-name>|<network-id>': connect to a user-defined network |
|
108 |
+ --no-healthcheck Disable any container-specified HEALTHCHECK |
|
109 |
+ --oom-kill-disable Disable OOM Killer |
|
110 |
+ --oom-score-adj int Tune host's OOM preferences (-1000 to 1000) |
|
111 |
+ --pid string PID namespace to use |
|
112 |
+ --pids-limit int Tune container pids limit (set -1 for unlimited) |
|
113 |
+ --privileged Give extended privileges to this container |
|
114 |
+ -p, --publish value Publish a container's port(s) to the host (default []) |
|
115 |
+ -P, --publish-all Publish all exposed ports to random ports |
|
116 |
+ --read-only Mount the container's root filesystem as read only |
|
117 |
+ --restart string Restart policy to apply when a container exits (default "no") |
|
118 |
+ Possible values are : no, on-failure[:max-retry], always, unless-stopped |
|
119 |
+ --rm Automatically remove the container when it exits |
|
120 |
+ --runtime string Runtime to use for this container |
|
121 |
+ --security-opt value Security Options (default []) |
|
122 |
+ --shm-size bytes Size of /dev/shm |
|
123 |
+ The format is `<number><unit>`. `number` must be greater than `0`. |
|
124 |
+ Unit is optional and can be `b` (bytes), `k` (kilobytes), `m` (megabytes), |
|
125 |
+ or `g` (gigabytes). If you omit the unit, the system uses bytes. |
|
126 |
+ --sig-proxy Proxy received signals to the process (default true) |
|
127 |
+ --stop-signal string Signal to stop a container (default "SIGTERM") |
|
128 |
+ --stop-timeout=10 Timeout (in seconds) to stop a container |
|
129 |
+ --storage-opt value Storage driver options for the container (default []) |
|
130 |
+ --sysctl value Sysctl options (default map[]) |
|
131 |
+ --tmpfs value Mount a tmpfs directory (default []) |
|
132 |
+ -t, --tty Allocate a pseudo-TTY |
|
133 |
+ --ulimit value Ulimit options (default []) |
|
134 |
+ -u, --user string Username or UID (format: <name|uid>[:<group|gid>]) |
|
135 |
+ --userns string User namespace to use |
|
136 |
+ 'host': Use the Docker host user namespace |
|
137 |
+ '': Use the Docker daemon user namespace specified by `--userns-remap` option. |
|
138 |
+ --uts string UTS namespace to use |
|
139 |
+ -v, --volume value Bind mount a volume (default []). The format |
|
140 |
+ is `[host-src:]container-dest[:<options>]`. |
|
141 |
+ The comma-delimited `options` are [rw|ro], |
|
142 |
+ [z|Z], [[r]shared|[r]slave|[r]private], |
|
143 |
+ [delegated|cached|consistent], and |
|
144 |
+ [nocopy]. The 'host-src' is an absolute path |
|
145 |
+ or a name value. |
|
146 |
+ --volume-driver string Optional volume driver for the container |
|
147 |
+ --volumes-from value Mount volumes from the specified container(s) (default []) |
|
148 |
+ -w, --workdir string Working directory inside the container |
|
148 | 149 |
``` |
149 | 150 |
|
150 | 151 |
## Description |
... | ... |
@@ -36,6 +36,7 @@ Options: |
36 | 36 |
--health-interval duration Time between running the check (ns|us|ms|s|m|h) |
37 | 37 |
--health-retries int Consecutive failures needed to report unhealthy |
38 | 38 |
--health-timeout duration Maximum time to allow one check to run (ns|us|ms|s|m|h) |
39 |
+ --health-start-period duration Start period for the container to initialize before counting retries towards unstable (ns|us|ms|s|m|h) (default 0s) |
|
39 | 40 |
--help Print usage |
40 | 41 |
--host list Set one or more custom host-to-IP mappings (host:ip) (default []) |
41 | 42 |
--hostname string Container hostname |
... | ... |
@@ -44,6 +44,7 @@ Options: |
44 | 44 |
--health-interval duration Time between running the check (ns|us|ms|s|m|h) |
45 | 45 |
--health-retries int Consecutive failures needed to report unhealthy |
46 | 46 |
--health-timeout duration Maximum time to allow one check to run (ns|us|ms|s|m|h) |
47 |
+ --health-start-period duration Start period for the container to initialize before counting retries towards unstable (ns|us|ms|s|m|h) (default 0s) |
|
47 | 48 |
--help Print usage |
48 | 49 |
--host-add list Add or update a custom host-to-IP mapping (host:ip) (default []) |
49 | 50 |
--host-rm list Remove a custom host-to-IP mapping (host:ip) (default []) |
... | ... |
@@ -1462,6 +1462,7 @@ Similarly the operator can set the **HOSTNAME** (Linux) or **COMPUTERNAME** (Win |
1462 | 1462 |
--health-interval Time between running the check |
1463 | 1463 |
--health-retries Consecutive failures needed to report unhealthy |
1464 | 1464 |
--health-timeout Maximum time to allow one check to run |
1465 |
+ --health-start-period Start period for the container to initialize before starting health-retries countdown |
|
1465 | 1466 |
--no-healthcheck Disable any container-specified HEALTHCHECK |
1466 | 1467 |
``` |
1467 | 1468 |
|