# Running HostMon in Docker

## What is HostMon?

> HostMon is a simple web-based host monitor and application dashboard. It can be used to monitor the real-time status of hosts and services running in your homelab environment. In addition to monitoring, HostMon has built-in Wake-On-LAN (WOL) capability, SSH client, real-time ping output and the ability to link to your existing Apache Guacamole installation to remotely control hosts from the within browser.
> The HostMon application is written in javascript and uses a SQLite database backend. -https://github.com/i12bretro/HostMon

## Installing Docker

1. Log into the Linux based device
2. Run the following commands in the terminal
   # install prerequisites
   sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg-agent -y
   # add docker gpg key
   curl -fsSL https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release)/gpg | sudo apt-key add -
   # add docker software repository
   sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release) $(lsb_release -cs) stable"
   # install docker
   sudo apt install docker-ce docker-compose containerd.io -y
   # enable and start docker service
   sudo systemctl enable docker && sudo systemctl start docker
   # add the current user to the docker group
   sudo usermod -aG docker $USER
   # reauthenticate for the new group membership to take effect
   su - $USER

## Running HostMon

1. Now that Docker is installed, run the following commands to setup the HostMon Docker container and run it
   # create working directories
   mkdir ~/docker/hostmon -p
   # set owner of working directories
   sudo chown "$USER":"$USER" ~/docker -R
   # create the hostmon docker container
   docker create -ti --name hostmon i12bretro/hostmon
   # export the hostmon database
   docker cp hostmon:/app/data/hostmon.db ~/docker/hostmon/hostmon.db
   # remove the temporary hostmon container
   docker rm hostmon -f
   # run hostmon with persistent database
   docker run -d --name hostmon -v ~/docker/hostmon:/app/data -p 3000:3000 --restart=unless-stopped i12bretro/hostmon
2. Open a web browser and navigate to http://DNSorIP:3000
3. Welcome to HostMon running in Docker

Documentation: https://hub.docker.com/r/i12bretro/hostmon