Podman容器耗尽AlmaLinux 9系统磁盘空间问题排查求助
Hey there, sorry to hear your root disk got completely filled up after running your first Podman container for a month—let's break this down step by step to identify the culprit and get this sorted out.
First off, a quick note: you used a Docker command (docker system prune --all --volumes) but since you're using Podman, it's better to stick to Podman-native commands for more accurate results. The equivalent Podman command is podman system prune -a --volumes, though it sounds like even this might not fix your core issue since you only freed 1.5GB. Let's dig deeper:
1. Check exactly what's using space in your Podman storage
Start by running podman system df—this will show you a breakdown of how much space is being used by images, containers, volumes, and build caches. This helps you quickly spot if unused resources are piling up, but since you only have one container running, the issue is likely within the running container itself.
2. Inspect the running container's internal storage
The overlay mount for your container is tied to your root partition, so any data written inside the container (that's not mounted to an external volume) will eat into your root disk space. Run these commands to investigate:
- First, get your container ID or name with
podman ps - Then check disk usage inside the container:
podman exec <container-id/name> df -h - To find large files/folders inside the container:
podman exec <container-id/name> du -sh /*
Common culprits here are:
- Unrotated application logs (e.g., logs in
/var/loginside the container that never get trimmed) - Temporary files or cached data that the app isn't cleaning up
- Databases or data stores that are growing and aren't mounted to an external volume
3. Check Podman's container logs on the host
Podman stores container logs locally by default, and if these logs aren't configured to rotate, they can grow to massive sizes. You can check the log file size with:
ls -lh /var/log/pods/<container-id>/<container-name>/<container-id>.log
If this file is huge, you'll need to set up log rotation. One easy fix is to switch the container's log driver to journald (which handles rotation automatically) when starting the container:
podman run --log-driver=journald ...
Or, if you prefer to keep using the default file driver, set up a logrotate rule for the log files.
4. Move container data to your unused /data partition
Your /data partition has plenty of free space (102G available), so you should mount any persistent data from your container to this partition. For example, if your app stores data in /app/data inside the container, stop the container and restart it with a volume mount:
podman run -v /data/container-data:/app/data ...
This way, all future data writes go to /data instead of your root partition.
5. Long-term cleanup strategy
Instead of relying on a cron job for a one-time prune, consider:
- Setting up regular log rotation for your container logs (either via journald or logrotate)
- Adding
podman system prune -a --volumesto cron to periodically clean up unused images, stopped containers, and orphaned volumes - Monitoring your root partition usage with tools like
ncdu(install withdnf install ncdu) to quickly spot growing files/folders
备注:内容来源于stack exchange,提问作者TSG




