diff --git a/How-to-Monitor-Docker-Containers.md b/How-to-Monitor-Docker-Containers.md index deddc55..4dce856 100644 --- a/How-to-Monitor-Docker-Containers.md +++ b/How-to-Monitor-Docker-Containers.md @@ -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://:2375"] + + #Secure option + "tls": true, + "tlscert": "/var/docker/server.pem", + "tlskey": "/var/docker/serverkey.pem", + "hosts": ["unix:///var/run/docker.sock","tcp://: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 diff --git a/img/docker-host.png b/img/docker-host.png new file mode 100644 index 0000000..3f9f9e9 Binary files /dev/null and b/img/docker-host.png differ