You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何查找容器已挂载的卷?Docker Compose中Prometheus服务/prometheus挂载来源排查

Tracking Down the Mysterious /prometheus Volume in Your Docker Setup

Great question! That unexpected /prometheus mount you're seeing in Portainer isn't a bug—it's actually a behavior baked into the official Prometheus Docker image. Here's how to track down all its details:

Why the Volume Exists (Even Without Defining It)

The official prom/prometheus:latest image includes a VOLUME /prometheus directive in its Dockerfile. Docker automatically creates an anonymous volume for this path whenever you run the container, even if you don't explicitly define it in your docker-compose.yml. This volume stores Prometheus' time-series data, so it persists even if the container is recreated.

Step-by-Step to Find the Volume Details

1. Use Docker CLI to Inspect the Container

Run this command to get full details about your Prometheus container's mounts:

docker inspect <your-prometheus-container-name-or-id>

Look for the Mounts section in the output. It will show:

  • Type: Should be volume (anonymous volume)
  • Name: A random alphanumeric ID assigned to the anonymous volume
  • Source: The actual path on your host machine (usually something like /var/lib/docker/volumes/<volume-id>/_data)
  • Destination: /prometheus (the path inside the container)

2. Check Portainer's Volumes Page

Portainer makes this even easier:

  • Navigate to the Volumes tab in Portainer
  • Use the search or filter to find volumes associated with your Prometheus container (look for the container name in the "Used By" column)
  • Click on the volume to view its details, including the host path and which containers it's mounted to

3. Verify the Compose Configuration

To see the full, expanded configuration Docker Compose uses (including the implicit volume), run:

docker compose config

You'll notice the /prometheus volume is automatically added under the volumes section of your Prometheus service.

Why You Might Not See the Folder

  • On the host: The path /var/lib/docker/volumes/... is owned by the root user, so you'll need to use sudo to list or access it (e.g., sudo ls /var/lib/docker/volumes/<volume-id>/_data).
  • In the container: The /prometheus folder definitely exists inside the container—try running docker exec -it <container-id> ls /prometheus to confirm it (you might need sudo here too if the container runs as a non-root user).

内容的提问来源于stack exchange,提问作者Eugen Konkov

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.27 13:43:12