Web server for docker logs
I was looking for a quick way to access my docker logs without the fuss of setting up a compicated monitoring tool like Grafana, Prometheus or other. This is a 3hours project to offer a webserver for docker logs for any home-labber.
The web server is served on port 8080 and is written to be exposed to all interfaces (i.e. Tailscale, VPN tunnel of any sort, LAN and/or web if your host is exposed to the web too). You can restrict the interfaces in the netcat command in the script.
sudo apt install gq netcat-traditional
Best is to set up the script as a service on Linux rather than run it directly from terminal. Below is a short recipe to run this as a service:
- Copy the repo into a folder
git clone https://github.com/melbv/docker-logs-web-server
- Save the file in your
systemdpath:
sudo cp /folder/where/repo/cloned/docker-logs-web.sh /usr/local/bin/docker-logs-web.sh
- Make the file executable
sudo chmod +x /usr/local/bin/docker-logs-web.sh
- Create the service file
sudo nano /etc/systemd/system/docker-logs-web.service
- Add the following
[Unit]
Description=Docker Logs Web Server
After=docker.service
Requires=docker.service
[Service]
Type=simple
User=root
ExecStart=/usr/local/bin/docker-logs-web.sh
Restart=always
RestartSec=5
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target- Reload
systemd, enable the service and start it
sudo systemctl daemon-reload
sudo systemctl enable docker-logs-web.service
sudo systemctl start docker-logs.web.service🎉 Well done! You now have a rudimentary webserver that allows you to access your docker logs without the fuss of modern monitoring tools.