docker compose v2 cannot override service healthcheck test
Description
I would like to override service healthcheck test. Works fine on v1, but docker compose v2 do not override test value. It to append new value to previous one.
Steps to reproduce the issue:
$ cat docker-compose.yml
version: '3.8'
services:
nginx:
image: nginx:1.21.4
healthcheck:
test: curl --fail -I http://localhost/ || exit 1
$ cat docker-compose.dev.yml
version: '3.8'
services:
nginx:
image: nginx:1.21.4
healthcheck:
test: exit 0
Describe the results you received:
V2 rather append healthcheck-test than override.
$ docker compose -f docker-compose.yml -f docker-compose.dev.yml config
services:
nginx:
healthcheck:
test:
- CMD-SHELL
- curl --fail -I http://localhost/ || exit 1
- CMD-SHELL
- exit 0
image: nginx:1.21.4
networks:
default: null
networks:
default:
name: compose-test_default
Describe the results you expected:
V1 override the healthcheck-test
$ docker-compose -f docker-compose.yml -f docker-compose.dev.yml config
services:
nginx:
healthcheck:
test: exit 0
image: nginx:1.21.4
version: '3.8'
Additional information you deem important (e.g. issue happens only occasionally):
Output of docker compose version:
$ docker compose version
Docker Compose version v2.1.1
Output of docker info:
$ docker info
Client:
Context: default
Debug Mode: false
Plugins:
buildx: Build with BuildKit (Docker Inc., v0.6.3)
compose: Docker Compose (Docker Inc., v2.1.1)
scan: Docker Scan (Docker Inc., 0.9.0)
Server:
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 7
Server Version: 20.10.10
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 5b46e404f6b9f661a205e28d59c982d3634148f8
runc version: v1.0.2-0-g52b36a2
init version: de40ad0
Security Options:
seccomp
Profile: default
Kernel Version: 5.10.47-linuxkit
Operating System: Docker Desktop
OSType: linux
Architecture: aarch64
CPUs: 4
Total Memory: 1.942GiB
Name: docker-desktop
ID: AP4U:4Z52:GPFJ:4X2R:VOVL:N3QO:5BHN:E2IH:PMEH:LI2G:4C7F:62W4
Docker Root Dir: /var/lib/docker
Debug Mode: false
HTTP Proxy: http.docker.internal:3128
HTTPS Proxy: http.docker.internal:3128
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Additional environment details:
I'm having exactly the same issue.
Output of docker compose version:
Docker Compose version 2.2.3
Output of docker info:
Client:
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc., v0.7.1-docker)
compose: Docker Compose (Docker Inc., 2.2.3)
Server:
Containers: 4
Running: 4
Paused: 0
Stopped: 0
Images: 72
Server Version: 20.10.12
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: false
userxattr: false
Logging Driver: json-file
Cgroup Driver: systemd
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 1407cab509ff0d96baa4f0eb6ff9980270e6e620.m
runc version: v1.1.0-0-g067aaf85
init version: de40ad0
Security Options:
seccomp
Profile: default
cgroupns
Kernel Version: 5.16.1-arch1-1
Operating System: Arch Linux
OSType: linux
Architecture: x86_64
CPUs: 16
Total Memory: 30.99GiB
Name: x-wing
ID: XL4S:IO7B:D5R2:A4XS:RGAR:OAOK:6ROK:SY6T:UI25:QW3L:RN64:OOIS
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support
WARNING: No cpu shares support
Exactly the same issue.
macOS: 12.3.1 docker compose version: v2.6.0 docker info:
Client:
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc., v0.8.2)
compose: Docker Compose (Docker Inc., v2.6.0)
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
scan: Docker Scan (Docker Inc., v0.17.0)
Server:
Containers: 6
Running: 4
Paused: 0
Stopped: 2
Images: 6
Server Version: 20.10.16
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runtime.v1.linux runc io.containerd.runc.v2
Default Runtime: runc
Init Binary: docker-init
containerd version: 212e8b6fa2f44b9c21b2798135fc6fb7c53efc16
runc version: v1.1.1-0-g52de29d
init version: de40ad0
Security Options:
seccomp
Profile: default
cgroupns
Kernel Version: 5.10.104-linuxkit
Operating System: Docker Desktop
OSType: linux
Architecture: aarch64
CPUs: 5
Total Memory: 7.667GiB
Name: docker-desktop
ID: NBDL:DSB6:NBKX:ZTUO:GSXJ:SX5A:P4YP:XAMI:HEC4:WM3F:UYP6:QG2E
Docker Root Dir: /var/lib/docker
Debug Mode: false
HTTP Proxy: http.docker.internal:3128
HTTPS Proxy: http.docker.internal:3128
No Proxy: hubproxy.docker.internal
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
hubproxy.docker.internal:5000
127.0.0.0/8
Live Restore Enabled: false
I got the same problem with docker version Docker version 20.10.17, build 100c701
Healthcheck's can't be overwritten with the override file.
Thanks for reporting this! I'm just noting my shared experience of issues merging healthcheck config with v2. In my case, I only wanted to override the interval key, but leave the actual test key that was defined in the primary compose config. In this situation, it's possible to get an error claiming that container for service "xxxxxxxxxxxx" has no healthcheck configured on a linux machine using compose version 2.14.2.
I tried to reproduce the reproduction scenario with latest release and get the expected behavior
$ docker compose -f compose.yml -f compose-dev.yml config
services:
nginx:
healthcheck:
test:
- CMD-SHELL
- exit 0
image: nginx:1.21.4
networks:
default: null
networks:
default:
name: truc_default
I guess this is a duplicate for https://github.com/docker/compose/issues/9756, fixed by https://github.com/compose-spec/compose-go/pull/321
@tboddyspargo if you can provide a concrete example to reproduce the side issue you describe, please open a new issue so we can investigate