From ca99d72edafc2a42a664153d1ff11ab535df14da Mon Sep 17 00:00:00 2001 From: Devarsh Date: Thu, 18 Dec 2025 13:08:10 +0530 Subject: [PATCH 1/2] add docker-inline-config approach Signed-off-by: Devarsh --- docs/guides/cadvisor.md | 74 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/docs/guides/cadvisor.md b/docs/guides/cadvisor.md index a4845fb28..d7ead8550 100644 --- a/docs/guides/cadvisor.md +++ b/docs/guides/cadvisor.md @@ -26,6 +26,7 @@ Now we'll need to create a Docker Compose [configuration](https://docs.docker.co In the same folder where you created the [`prometheus.yml`](#prometheus-configuration) file, create a `docker-compose.yml` file and populate it with this Docker Compose configuration: +### Using Bind Mounts ```yaml version: '3.2' services: @@ -92,6 +93,79 @@ cadvisor /usr/bin/cadvisor -logtostderr Up 8080/tcp prometheus /bin/prometheus --config.f ... Up 0.0.0.0:9090->9090/tcp redis docker-entrypoint.sh redis ... Up 0.0.0.0:6379->6379/tcp ``` +### Alternative: Using Inline Docker Configs (Remote Deployments) + +If you're managing a remote Docker host and prefer to keep all configuration within the docker-compose.yml file (avoiding the need to manage separate config files on the host), you can use Docker's configs feature: + +```yaml +version: '3.8' + +configs: + prometheus_config: + content: | + global: + scrape_interval: 15s + evaluation_interval: 15s + + scrape_configs: + - job_name: 'prometheus' + static_configs: + - targets: ['localhost:9090'] + + - job_name: 'cadvisor' + scrape_interval: 5s + static_configs: + - targets: ['cadvisor:8080'] + +services: + prometheus: + image: prom/prometheus:latest + container_name: prometheus + ports: + - 9090:9090 + command: + - --config.file=/etc/prometheus/prometheus.yml + configs: + - source: prometheus_config + target: /etc/prometheus/prometheus.yml + uid: "65534" # Required: numeric UID for 'nobody' user + gid: "65534" # Required: numeric GID for 'nobody' group + mode: 0400 # Required: read-only permissions + depends_on: + - cadvisor + + cadvisor: + image: gcr.io/cadvisor/cadvisor:latest + container_name: cadvisor + ports: + - 8080:8080 + volumes: + - /:/rootfs:ro + - /var/run:/var/run:rw + - /sys:/sys:ro + - /var/lib/docker/:/var/lib/docker:ro + depends_on: + - redis + + redis: + image: redis:latest + container_name: redis + ports: + - 6379:6379 +``` + +#### Important Notes + +⚠️ **Required Fields**: When using Docker `configs`, you **must** explicitly specify `uid`, `gid`, and `mode` as numeric values: + +- `uid: "65534"` - The numeric user ID (65534 = `nobody` user in the Prometheus image) +- `gid: "65534"` - The numeric group ID (65534 = `nobody` group) +- `mode: 0400` - File permissions (read-only for owner) + +Omitting these fields or using string values like `"nobody"` will cause the following error: +``` +strconv.Atoi: parsing "nobody": invalid syntax +``` ## Exploring the cAdvisor web UI From 306436321e962ed235dfd3b5c1ee3de027b66eb0 Mon Sep 17 00:00:00 2001 From: Devarsh Date: Thu, 18 Dec 2025 14:18:11 +0530 Subject: [PATCH 2/2] remove prometheus monitoring and global object Signed-off-by: Devarsh --- docs/guides/cadvisor.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/docs/guides/cadvisor.md b/docs/guides/cadvisor.md index d7ead8550..f786d5d2e 100644 --- a/docs/guides/cadvisor.md +++ b/docs/guides/cadvisor.md @@ -103,15 +103,7 @@ version: '3.8' configs: prometheus_config: content: | - global: - scrape_interval: 15s - evaluation_interval: 15s - scrape_configs: - - job_name: 'prometheus' - static_configs: - - targets: ['localhost:9090'] - - job_name: 'cadvisor' scrape_interval: 5s static_configs: