Using DDEV Local a project will sometimes fail the healthcheck, but then eventually become available. How could someone disable the healthcheck in order to better diagnose what is happening in a container?
Using DDEV Local a project will sometimes fail the healthcheck, but then eventually become available. How could someone disable the healthcheck in order to better diagnose what is happening in a container?
Thanks to the integration of docker-composer we can create a compose file for healthcheck and adjust its settings as needed.
To start add a docker-compose.healthcheck.yaml file to your .ddev directory.
Then to disable the healthcheck it should look something like this:
version: '3.6'
services:
web:
healthcheck:
test: ['CMD','true'] //disable the healthcheck
In this example we use ['CMD','true'] to force the test to pass, rather than using disable:true, because the disable key cannot be paired with other options which are set by default.
Additionally, if you would like to adjust the timeout before a container fails you can adjust the compose file like so:
version: '3.6'
services:
web:
healthcheck:
timeout: 30s //set how long before healthcheck fails
You can also familiarize yourself more with the available options for healthcheck via the Compose File Healthcheck docs.
To disable Docker healthcheck you can use test: ["NONE"].
services:
your-service:
healthcheck:
test: ["NONE"]
https://docs.docker.com/compose/compose-file/compose-file-v3/#healthcheck
I use docker-compose version 1.25.0 and Docker Compose Document version '3.1'.
It doesn't work for me, but it is described in the documentation.
healthcheck:
disable: true
But, I don't know a reason, a part of docker-compose.override.yml don't work with that settings. Parents docker-compose.yml have health settings, I think it makes the error.
ERROR: Service "nginx" defines an invalid healthcheck: "disable: true" cannot be combined with other options
To disable it in docker-compose.override.yml I use the following settings:
healthcheck:
test: ["CMD", "none"]
I think another way to disable healthcheck is using different docker-compose configs:
docker-compose.yml without healthcheck.docker-compose.healthcheck.yml with healthcheck that will be combined with the parent docker-compose.yml:# With healthcheck
docker-compose -f docker-compose.yml -f docker-compose.healthcheck.yml up
# With override
docker-compose up
# Without override and healthcheck
docker-compose -f docker-compose.yml up