PairDrop/docs/docker-swarm-usage.md

48 lines
1.6 KiB
Markdown
Raw Normal View History

2023-03-18 23:52:33 +00:00
# Docker Swarm Usage
## Healthcheck
2023-07-08 12:59:58 +00:00
The [Docker Image](../Dockerfile) includes a health check with the following options:
2023-03-18 23:52:33 +00:00
```
--interval=30s
```
2023-07-08 12:59:58 +00:00
> Specifies the time interval to run the health check. \
> In this case, the health check is performed every 30 seconds.
<br>
2023-03-18 23:52:33 +00:00
```
--timeout=10s
```
2023-08-11 18:59:26 +00:00
> Specifies the amount of time to wait for a response from the \"HEALTHCHECK\" command. \
2023-07-08 12:59:58 +00:00
> If the response does not arrive within 10 seconds, the health check fails.
<br>
2023-03-18 23:52:33 +00:00
```
--start-period=5s
```
2023-07-08 12:59:58 +00:00
> Specifies the amount of time to wait before starting the health check process. \
> In this case, the health check process will begin 5 seconds after the container is started.
<br>
```
--retries=3
```
2023-07-08 12:59:58 +00:00
> Specifies the number of times Docker should retry the health check \
> before considering the container to be unhealthy.
<br>
2023-07-08 12:59:58 +00:00
The CMD instruction is used to define the command that will be run as part of the health check. \
In this case, the command is `wget --quiet --tries=1 --spider http://localhost:3000/ || exit 1`. \
This command will attempt to connect to `http://localhost:3000/` \
and if it fails it will exit with a status code of `1`. \
If this command returns a status code other than `0`, the health check fails.
2023-08-11 18:59:26 +00:00
Overall, this \"HEALTHCHECK\" instruction is defining a health check process \
2023-07-08 12:59:58 +00:00
that runs every 30 seconds, and waits up to 10 seconds for a response, \
begins 5 seconds after the container is started, and retries up to 3 times. \
The health check attempts to connect to http://localhost:3000/ \
and will considers the container unhealthy if unable to connect.
2023-03-18 23:52:33 +00:00