|
| 1 | +## Deploying Dozzle as a Central Hub and Connecting Agents |
| 2 | + |
| 3 | +Dozzle is a real-time log viewer for Docker containers. This guide demonstrates how to set up a central Dozzle instance (the hub) and connect Dozzle agents running on other systems to it. |
| 4 | + |
| 5 | +**Prerequisites:** |
| 6 | + |
| 7 | +* Docker and Docker Compose installed on your hub system. |
| 8 | +* Docker installed on the agent systems. |
| 9 | +* Network connectivity between the hub and agent systems. |
| 10 | + |
| 11 | +**Step 1: Deploying the Dozzle Hub** |
| 12 | + |
| 13 | +1. **Create a `docker-compose.yml` file:** |
| 14 | + |
| 15 | + Create a file named `docker-compose.yml` on your hub system with the following content: |
| 16 | + |
| 17 | + ```yaml |
| 18 | + |
| 19 | + services: |
| 20 | + dozzle: |
| 21 | + image: amir20/dozzle:latest |
| 22 | + ports: |
| 23 | + - "8080:8080" |
| 24 | + volumes: |
| 25 | + - /var/run/docker.sock:/var/run/docker.sock:ro |
| 26 | + environment: |
| 27 | + - DOZZLE_BASE=/dozzle/ |
| 28 | + - DOZZLE_PORT=8080 |
| 29 | + - DOZZLE_HUB=true |
| 30 | + ``` |
| 31 | +
|
| 32 | + **Explanation:** |
| 33 | +
|
| 34 | + * `image: amir20/dozzle:latest`: Uses the latest Dozzle image. |
| 35 | + * `ports: "8080:8080"`: Exposes Dozzle on port 8080 of the host. |
| 36 | + * `volumes: /var/run/docker.sock:/var/run/docker.sock:ro`: Mounts the Docker socket, allowing Dozzle to access container logs. |
| 37 | + * `environment:`: Sets environment variables: |
| 38 | + * `DOZZLE_BASE=/dozzle/`: Sets the base URL path for Dozzle. |
| 39 | + * `DOZZLE_PORT=8080`: Specifies the port Dozzle listens on. |
| 40 | + * `DOZZLE_HUB=true`: Enables hub mode. |
| 41 | + |
| 42 | +2. **Start the Dozzle hub:** |
| 43 | + |
| 44 | + Navigate to the directory containing `docker-compose.yml` and run: |
| 45 | + |
| 46 | + ```bash |
| 47 | + docker-compose up -d |
| 48 | + ``` |
| 49 | + |
| 50 | +3. **Access the Dozzle hub:** |
| 51 | + |
| 52 | + Open your web browser and navigate to `http://<hub-ip>:8080/dozzle/`. You should see the Dozzle interface. |
| 53 | + |
| 54 | +**Step 2: Deploying Dozzle Agents** |
| 55 | + |
| 56 | +1. **Create a `docker-compose.yml` file:** |
| 57 | + |
| 58 | + On each agent system, create a `docker-compose.yml` file with the following content: |
| 59 | + |
| 60 | + ```yaml |
| 61 | + |
| 62 | + services: |
| 63 | + dozzle-agent: |
| 64 | + image: amir20/dozzle:latest |
| 65 | + volumes: |
| 66 | + - /var/run/docker.sock:/var/run/docker.sock:ro |
| 67 | + environment: |
| 68 | + - DOZZLE_HUB_URL=http://<hub-ip>:8080/dozzle/ |
| 69 | + - DOZZLE_HOSTNAME=<agent-hostname> |
| 70 | + ``` |
| 71 | + |
| 72 | + **Explanation:** |
| 73 | + |
| 74 | + * `image: amir20/dozzle:latest`: Uses the latest Dozzle image. |
| 75 | + * `volumes: /var/run/docker.sock:/var/run/docker.sock:ro`: Mounts the Docker socket. |
| 76 | + * `environment:`: Sets environment variables: |
| 77 | + * `DOZZLE_HUB_URL=http://<hub-ip>:8080/dozzle/`: Specifies the URL of the Dozzle hub. Replace `<hub-ip>` with the IP address of your hub system. |
| 78 | + * `DOZZLE_HOSTNAME=<agent-hostname>`: Sets the hostname of the agent system. Replace `<agent-hostname>` with a unique identifier for the agent (e.g., the hostname or a custom name). |
| 79 | + |
| 80 | +2. **Start the Dozzle agent:** |
| 81 | + |
| 82 | + Navigate to the directory containing `docker-compose.yml` and run: |
| 83 | + |
| 84 | + ```bash |
| 85 | + docker-compose up -d |
| 86 | + ``` |
| 87 | + |
| 88 | +**Step 3: Viewing Logs in the Dozzle Hub** |
| 89 | + |
| 90 | +1. **Refresh the Dozzle hub:** |
| 91 | + |
| 92 | + Refresh the Dozzle hub web interface (`http://<hub-ip>:8080/dozzle/`). |
| 93 | + |
| 94 | +2. **Select the agent:** |
| 95 | + |
| 96 | + You should now see the hostname of the agent system in the Dozzle interface's dropdown menu. Select the agent's hostname to view the logs from that system. |
| 97 | + |
| 98 | +3. **View container logs:** |
| 99 | + |
| 100 | + You can now select and view the logs of the Docker containers running on the agent system. |
| 101 | + |
| 102 | +**Important Considerations:** |
| 103 | + |
| 104 | +* **Security:** Exposing the Docker socket can be a security risk. Ensure that your network is properly secured. Consider using a reverse proxy with authentication for the Dozzle hub. |
| 105 | +* **Network Configuration:** Ensure that the agent systems can reach the Dozzle hub on port 8080. Firewalls or network configurations may need to be adjusted. |
| 106 | +* **Hostname Uniqueness:** Use unique hostnames for each agent to avoid conflicts in the Dozzle hub. |
| 107 | +* **Persistent Configuration:** For production environments, consider using Docker volumes to persist Dozzle's configuration and data. |
| 108 | +* **TLS/SSL:** Configure TLS/SSL for secure communication between the agents and the hub, especially if transmitting data over untrusted networks. |
| 109 | +* **Authentication:** Implement authentication for the Dozzle Hub to restrict access. This can be done with traefik, nginx, or other reverse proxies. |
| 110 | + |
0 commit comments