Docker swarm configuration
Recently I deployed a service that has no HTTP endpoints, instead I created a file in the container on startup that is deleted when the service is unhealthy.
Here is the config to check for the file presence, once deleted and the healthcheck fails a few times the service will be restarted:
deploy:
replicas: 1
restart_policy:
condition: on-failure
healthcheck:
test: ["CMD", "test", "-f", "/path/to/file"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
Or if you’re deploying the apps using Dokploy as I am this is the config:
{
"Test": [
"CMD",
"test",
"-f",
"/path/to/file"
],
"Interval": 30000000000,
"Timeout": 10000000000,
"StartPeriod": 30000000000,
"Retries": 3
}
Happpy deploying!