Merge pull request #18 from trekie86/master

Add documentation on monitoring Docker via TCP
Louis Lam 2022-10-28 01:36:57 +08:00 committed by GitHub
commit 95179677c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 1 deletions

@ -20,7 +20,45 @@ volumes:
### (Method 2) TCP - Bridge Mode
TODO
**Expose TCP port**
To enable TCP monitoring, you need to first expose the Docker daemon on a TCP port. The primary documentation is available [here](https://docs.docker.com/config/daemon/) but the example below provides some quick options.
Update the daemon configuration located at `/etc/docker/daemon.json`:
```json
{
#any additional parameters should be kept
#Insecure option, only use this if you are running on a closed network
"hosts": ["unix:///var/run/docker.sock","tcp://<host IP address>:2375"]
#Secure option
"tls": true,
"tlscert": "/var/docker/server.pem",
"tlskey": "/var/docker/serverkey.pem",
"hosts": ["unix:///var/run/docker.sock","tcp://<host IP address>:2376"]
}
```
Restart the daemon using `sudo systemctl restart docker.service`.
If the daemon fails to start, it may be because there are duplicate keys, in this case hosts, -H, that is already part of the daemon configuration.
You can edit the startup configuration using `sudo systemctl edit docker.service`.
```toml
[Service]
#The blank ExecStart is required to clear the current entry point
ExecStart=
#Replace the existing ExecStart but only remove the properties that you have added into the daemon.json file, leave all else the same.
ExecStart=/usr/bin/dockerd --containerd=/run/containerd/containerd.sock
```
My original ExecStart was: `ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock`, note the -H that would cause a duplicate property error.
**Update uptime-kuma**
Add a new Docker host and choose TCP as the option. Specify the IP address of the host and the TCP port you exposed, as seen below.
![Docker host monitor](img/docker-host.png)
## Related Disscussion

BIN
img/docker-host.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB