Skip to content

Commit a0d6fcb

Browse files
authored
Merge pull request #2802 from devarsh10/enh/add-inline-docker-config
update cadvisor doc to support inlini config
2 parents a27b972 + 3064363 commit a0d6fcb

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

docs/guides/cadvisor.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Now we'll need to create a Docker Compose [configuration](https://docs.docker.co
2626
2727
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:
2828

29+
### Using Bind Mounts
2930
```yaml
3031
version: '3.2'
3132
services:
@@ -92,6 +93,71 @@ cadvisor /usr/bin/cadvisor -logtostderr Up 8080/tcp
9293
prometheus /bin/prometheus --config.f ... Up 0.0.0.0:9090->9090/tcp
9394
redis docker-entrypoint.sh redis ... Up 0.0.0.0:6379->6379/tcp
9495
```
96+
### Alternative: Using Inline Docker Configs (Remote Deployments)
97+
98+
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:
99+
100+
```yaml
101+
version: '3.8'
102+
103+
configs:
104+
prometheus_config:
105+
content: |
106+
scrape_configs:
107+
- job_name: 'cadvisor'
108+
scrape_interval: 5s
109+
static_configs:
110+
- targets: ['cadvisor:8080']
111+
112+
services:
113+
prometheus:
114+
image: prom/prometheus:latest
115+
container_name: prometheus
116+
ports:
117+
- 9090:9090
118+
command:
119+
- --config.file=/etc/prometheus/prometheus.yml
120+
configs:
121+
- source: prometheus_config
122+
target: /etc/prometheus/prometheus.yml
123+
uid: "65534" # Required: numeric UID for 'nobody' user
124+
gid: "65534" # Required: numeric GID for 'nobody' group
125+
mode: 0400 # Required: read-only permissions
126+
depends_on:
127+
- cadvisor
128+
129+
cadvisor:
130+
image: gcr.io/cadvisor/cadvisor:latest
131+
container_name: cadvisor
132+
ports:
133+
- 8080:8080
134+
volumes:
135+
- /:/rootfs:ro
136+
- /var/run:/var/run:rw
137+
- /sys:/sys:ro
138+
- /var/lib/docker/:/var/lib/docker:ro
139+
depends_on:
140+
- redis
141+
142+
redis:
143+
image: redis:latest
144+
container_name: redis
145+
ports:
146+
- 6379:6379
147+
```
148+
149+
#### Important Notes
150+
151+
⚠️ **Required Fields**: When using Docker `configs`, you **must** explicitly specify `uid`, `gid`, and `mode` as numeric values:
152+
153+
- `uid: "65534"` - The numeric user ID (65534 = `nobody` user in the Prometheus image)
154+
- `gid: "65534"` - The numeric group ID (65534 = `nobody` group)
155+
- `mode: 0400` - File permissions (read-only for owner)
156+
157+
Omitting these fields or using string values like `"nobody"` will cause the following error:
158+
```
159+
strconv.Atoi: parsing "nobody": invalid syntax
160+
```
95161

96162
## Exploring the cAdvisor web UI
97163

0 commit comments

Comments
 (0)