Deploying Beszel with Docker Compose¶
Introduction to Beszel¶
Beszel is a lightweight, self-hosted server monitoring hub that collects CPU, memory, disk, and network metrics from agents running on your servers. It provides an intuitive web dashboard to monitor all your systems in one place. This guide details deploying Beszel using Docker Compose.
Docker Compose Configuration for Beszel¶
Here's how to set up Beszel using Docker Compose, explaining each component of the configuration.
Docker Compose File (docker-compose.yml)¶
services:
beszel:
image: 'henrygd/beszel' # Specifies the Beszel Docker image.
container_name: 'beszel' # Names the container for easier management.
restart: unless-stopped # Ensures the container restarts automatically unless stopped.
ports:
- '8090:8090' # Maps port 8090 on the host to port 8090 in the container.
volumes:
- ./beszel_data:/beszel_data # Persists data in a bind mount.
Explanation of Key Components¶
- Image: Specifies the Docker image for Beszel, ensuring consistency and compatibility.
- Ports: Maps the host port to the container port where Beszel is accessible. Port
8090is used for both the host and the container. - Volumes: Uses a bind mount (
./beszel_data:/beszel_data) to store persistent data. This is crucial for maintaining data across container restarts or updates.
Preparing for Deployment¶
Ensure that the volume directory exists or Docker will create it at runtime:
This command prepares a dedicated storage space for Beszel's data, avoiding data loss during updates or restarts.
Deployment¶
To deploy Beszel, navigate to the directory containing your docker-compose.yml and run:
This command starts the Beszel service in detached mode, running in the background.
Accessing Beszel¶
After deployment, Beszel will be accessible at http://<your-server-ip>:8090 based on your port configuration. This setup ensures that Beszel is ready to collect metrics from your self-hosted environment.
The Beszel agent is required
Beszel requires a lightweight agent installed on each host you want to monitor. Without the agent, the Beszel hub will show no data.
Add the agent to each monitored host using the following Docker Compose snippet:
services:
beszel-agent:
image: henrygd/beszel-agent
container_name: beszel-agent
restart: unless-stopped
network_mode: host
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
LISTEN_PORT: 45876
HUB_URL: http://<beszel-hub-ip>:8090
Replace <beszel-hub-ip> with the IP of your Beszel hub container.
Conclusion¶
Deploying Beszel with Docker Compose gives you a lightweight, self-hosted monitoring hub for all your servers. Install the Beszel agent on each host you want to monitor, then add it via the web dashboard to start collecting metrics.
If there is an issue with this guide or you wish to suggest changes, please raise an issue on GitHub.