Skip to content

Healthcheck starts while building an image #37362

@heycalmdown

Description

@heycalmdown

Description

The healthcheck script has started while an image is building, despite the document told "The health check will first run interval seconds after the container is started". It can be easily reproduced by following steps.

Steps to reproduce the issue:

FROM busybox
HEALTHCHECK --interval=1s --timeout=5s --start-period=5s --retries=3 CMD ping google.com # any script that doesn't work before the build steps have finished
RUN sleep 100000 # any time taking statement
  1. docker build .
  2. ps -aux ping in a different terminal

Describe the results you received:

$ ps -aux | grep ping
root     12762  0.1  0.0   1228     4 ?        Ss   14:48   0:00 ping google.com
root     12790  0.2  0.0   1228     4 ?        Ss   14:48   0:00 ping google.com
root     12827  2.0  0.0   1228     4 ?        Ss   14:48   0:00 ping google.com
kson     12838  0.0  0.0  15504   944 pts/1    S+   14:48   0:00 grep --color=auto ping

The list is growing.

Describe the results you expected:

$ ps -aux | grep ping
kson     12772  0.0  0.0  15504   972 pts/1    S+   14:48   0:00 grep --color=auto ping

Healthcheck script starts when the container started. No result expected.

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

Client:
 Version:      18.03.1-ce
 API version:  1.37
 Go version:   go1.9.5
 Git commit:   9ee9f40
 Built:        Thu Apr 26 07:17:20 2018
 OS/Arch:      linux/amd64
 Experimental: false
 Orchestrator: swarm

Server:
 Engine:
  Version:      18.03.1-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.9.5
  Git commit:   9ee9f40
  Built:        Thu Apr 26 07:15:30 2018
  OS/Arch:      linux/amd64
  Experimental: false

I've tested on below 4 versions.

* docker-ce | 18.03.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
* docker-ce | 18.03.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
* docker-ce | 17.12.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
* docker-ce | 17.12.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages

Output of docker info:

Containers: 1
 Running: 0
 Paused: 0
 Stopped: 1
Images: 37
Server Version: 18.03.1-ce
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 201
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 773c489c9c1b21a6d78b5c538cd395416ec50f88
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.4.0-87-generic
Operating System: Ubuntu 16.04.3 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 992.3MiB
Name: fo4-aws-ldt
ID: O26T:JPIN:5UVX:J7R5:PFH6:BG2X:KU6G:OQB2:L6PQ:ELPE:EPTP:H3M6
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: No swap limit support

Additional environment details (AWS, VirtualBox, physical, etc.):

  • VirtualBox on Mac
  • Physical

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions